在python中键入时将输入转换为*的最佳方法是什么?

时间:2020-01-07 22:36:43

标签: python input

所以我是编程和python的初学者,并且最近才了解输入知识,所以我写了一个简短而基本的登录/注册脚本,它实际上并没有做我只是为了娱乐而做的任何事情。这是完整的代码。

    confirm = getpass.getpass()
    user=input("Choose your username:")
    password=input("Choose your password:")
    confirm=input("Confirm your password:")
    if(password==confirm):
        print("Password matches")
        emal=input("Enter your email:")
        print("Thank you for registering")
        close=input("Press Enter to close the prompt")
    while(password!=confirm):
        print("Password does not match")
        close2=input("Press Enter to try confirming the password again")
        password=input("Choose your password:")
        confirm=input("Confirm your password:")

所以基本上我只是想使其更凉爽,所以我想知道如何在输入时将输入的两个密码都输入并确认转换为*。最好只重写密码代码并确认输入,还是可以以某种方式升级原始代码。我尝试过getpass,但由于我是个初学者,因此我需要一些帮助来进行操作,并查看我是否还可以将其用于确认。

1 个答案:

答案 0 :(得分:1)

EmbeddedResource

不会将您的输出打印到终端(它不会给您星号,而是meh)