【问题标题】:How to make lines of text go away in python [duplicate]如何在python中使文本行消失[重复]
【发布时间】:2020-09-30 18:55:34
【问题描述】:

所以我有这个需要密码的代码。

password = input('Enter your password: ')
if password == 'yellow':
    print('You have made it inside the computer')

但我想做到这一点,当我按下回车键时,“输入您的密码:黄色”的行会消失。我查了这个并访问了很多网站,但没有一个回答我的问题。至少,我想知道怎么做,这样当我输入“yellow”时,它会显示为“******”或类似的东西。

【问题讨论】:

    标签: python passwords


    【解决方案1】:

    为此,您将需要外部库。见this one

    例如

    import getpass 
      
    p = getpass.getpass(prompt='Your favorite flower? ') 
      
    if p.lower() == 'rose': 
        print('Welcome..!!!') 
    else: 
        print('The answer entered by you is incorrect..!!!') 
    

    【讨论】:

      【解决方案2】:

      导入 getpass 模块。

      import getpass 
      
      password = getpass.getpass('Enter your password: ')
      if password == 'yellow':
          print('You have made it inside the computer')
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-05-08
        • 2021-09-01
        • 2019-10-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多