【Python笔记】输入密码不显示

版权声明:看不尽的尘埃版权所有,转载请注明出处 https://blog.csdn.net/weixin_42936566/article/details/87858195

为了安全,很多时候,我们需要让密码不能显示出来。在Python中只要导入getpass模块即可达到这个目的。

代码:

#!/usr/bin/python
# -*- coding:utf-8 -*-
# wirter:En_dust

import getpass

user = input("username:")
password = getpass.getpass("password:")
print("\n-------------result----------\nusername:%s\npassword:%s"% (user,password))

运行效果:

注意:

该方法不能在编辑器中运行

猜你喜欢

转载自blog.csdn.net/weixin_42936566/article/details/87858195