如何在python中消除文本行
所以我有一个需要密码的代码如何在python中消除文本行,python,passwords,Python,Passwords,所以我有一个需要密码的代码 password = input('Enter your password: ') if password == 'yellow': print('You have made it inside the computer') 但我想这样做,当我按下回车键时,“输入你的密码:黄色”这行就会消失。我查了一下,访问了很多网站,但没有一个回答我的问题。至少,我想知道如何设置它,这样当我键入“黄色”时,它会显示为“******”或类似的内容。您需要外部库来实现这一点。
password = input('Enter your password: ')
if password == 'yellow':
print('You have made it inside the computer')
但我想这样做,当我按下回车键时,“输入你的密码:黄色”这行就会消失。我查了一下,访问了很多网站,但没有一个回答我的问题。至少,我想知道如何设置它,这样当我键入“黄色”时,它会显示为“******”或类似的内容。您需要外部库来实现这一点。看 前
为此,您需要外部库。看 前
导入getpass模块
import getpass
password = getpass.getpass('Enter your password: ')
if password == 'yellow':
print('You have made it inside the computer')
导入getpass模块
import getpass
password = getpass.getpass('Enter your password: ')
if password == 'yellow':
print('You have made it inside the computer')