我正在尝试创建密码输入。我知道 getpass.getpass
,但是当我将它置于空闲状态时,它通过了一个错误提示“密码可能被回显”。
我的代码:
import getpass
p = getpass.getpass()
print("You entered:") + p
这可能行不通,因为我使用的是 Python 3.2.3
最佳答案
来自getpass
文档:
Note If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself.
还有:
If echo free input is unavailable
getpass()
falls back to printing a warning message to stream and reading fromsys.stdin
and issuing aGetPassWarning
.
所以您可能只是在 IDLE 环境中没有可用的echo free input
(例如,您没有从 shell 启动它)。
关于python - Getpass 输入 Python 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34396842/