我试图在Python3.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")
为此使用^{} 模块
getpass.getpass()
允许用户输入输入而无需回显(打印到终端)您可能还想查看^{} 以了解程序的一些功能
相关问题 更多 >
编程相关推荐