2016-06-15 4 views
-1

파이썬 3.5.1에서 간단한 사용자 이름과 패스워드 스크립트를 만들려고하는데, 사용자가 패스워드를 입력하는 방법을 알아낼 수 없다. 그리고 패스워드를 별표로 덮어서 읽을 수 없다. .암호를 가장하려면 문자열의 문자를 어떻게 바꿀 수 있습니까?

이 지금까지 내 코드입니다 :

import time 
print ("Hello!") 
time.sleep(1) 
print ("Welcome to the Username and Password python test!") 
time.sleep(3) 
Username = input ("Please enter your desired Username ") 
time.sleep(1) 
print ("Your username is "+ Username) 
time.sleep(1) 
Q1 = input ("Is this correct? 'Y' or 'N' ") 
if Q1 == "N": 
    Q2 = input ("Would you like to change it? ") 
    if Q2 == "Y": Username = input ("Please re enter your Username ") 
    print ("Your Username is now "+ Username) 
    time.sleep(2) 
    print ("You cannot change your Username now") 
    time.sleep(2) 
if Q1 == "Y": time.sleep(1) 
Password = input ("Please input your Password ") 
time.sleep(3) 
Q3 = input ("Please enter your Username ") 
if Q3 == Username: 
    time.sleep(1) 
    Q4 = input ("Please now input your Password ") 
    time.sleep(1) 
    if Q4 == Password: 
     print ("Correct") 
     time.sleep(2) 
     print ("Thank you for using the Username and Password python test") 
    else: 
     print ("Incorrect Password") 
else: 
    print ("Username not found") 
+0

안녕하세요. 질문을 편집하고 해당 코드가 어떻게되는지 설명하십시오. – kebs

답변

1

이의 getpass 모듈을 사용합니다. getpass.getpass()을 사용하면 사용자가 에코 (터미널에 인쇄)없이 입력 할 수 있습니다.

프로그램 기능 중 일부는 getpass.user()을보고 싶을 수도 있습니다.

관련 문제