getpass
import getpass username = input("username:") password = getpass.getpass("password:") print(username,password)
在pycharm中运行下面的代码时不能输入密码(软件问题,代码没错),选择命令行执行
密码默认不显示
例子:
import getpass _usename = "fww" _password = "123" username = input("username:") password = getpass.getpass("password:") print(username,password) if _usename == username and _password == password: print("Welcome user {name} login".format(name = username)) else: ; print("Invalid username or password")
结果显示
原文链接:/python/526616.html