【发布时间】:2013-07-08 23:00:49
【问题描述】:
如何防止输入回显??
尝试过“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:
>>>
有没有一种简单的方法可以防止输入回显?
【问题讨论】:
-
Windows 和 Windows 上的终端有何不同?
-
我相信一个是IDLE,另一个是终端。
-
我认为这个问题需要澄清一下,如果是
IDLE,至少应该在问题中提及。 -
是的,第一个在从IDLE启动的Shell中,第二个在从命令行启动的Shell中。两个都在同一台电脑上,我还以为是同一个python shell呢。
-
我放弃了.... 在 Python 3.3.x 上,没有简单的解决方法可以在没有回显的情况下获得输入。和空闲外壳。不敢相信,但确实如此! :-(
标签: python python-3.x