如何防止输入回声?
尝试过“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,并且由于安全原因而失败。
关于python - 有没有简单的方法来防止输入回声?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17520292/