当在程序开发时输入密码规定都是需要密文输入的,以下是python密码密文输入的方法:
1
2
3
4
5
6
7
8
9
10
11
|
#!/usr/bin/env python # -*- coding:utf-8 -*- import getpass #导入库
username = input ( "username:" )
password = getpass.getpass( "password:" )
print (username, password)
#执行结果 username:xcn password: xcn admin
|
本文转自 baishuchao 51CTO博客,原文链接:http://blog.51cto.com/baishuchao/1932895