Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中消除文本行_Python_Passwords - Fatal编程技术网

如何在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')