有没有简单的方法可以防止回声输入



如何防止回声输入??

尝试过"getpass()",但没有成功。

在Windows IDLE上,它不工作

    Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import getpass
>>> p = getpass.getpass(prompt="Input: ")
Warning: Password input may be echoed.
Input: abc <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< It still echos..

在Windows的终端上,它工作于

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import getpass
>>> p = getpass.getpass(prompt="Input: ")
Input:
>>>

有没有一种简单的方法可以防止回声输入?

我假设您的第一个例子是IDLE。

从getpass.win_getpass():

if sys.stdin is not sys.__stdin__:
    return fallback_getpass(prompt, stream)

IDLE用不同的对象替换sys.stdin。getpass检测到有人包装了stdin,但由于安全原因而失败。

请参阅:http://bugs.python.org/issue9290

最新更新