怎样将标准输入的数据隐藏起来

怎样将标准输入的数据隐藏起来

比如说,输入密码时显示"*****".
看getpass模块的函数是怎么写的。
3x.
但是在我的机器上,windows 下的getpass()似乎有问题。

[Copy to clipboard] [ - ]
CODE:
Warning: Problem with getpass. Passwords may be echoed.

你试过吗?
试过,如下


[Copy to clipboard] [ - ]
CODE:
>>> from getpass import getpass
>>> getpass()
Warning: Problem with getpass. Passwords may be echoed.
Password: 123456
'123456'

http://mail.python.org/pipermail/python-list/2003-March/154015.html

不要在idle或pythonwin里面试

[Copy to clipboard] [ - ]
CODE:
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from getpass import getpass
>>> getpass()
Password:
'123456'
>>>

OK! Thank you.