当我运行这段代码时:
import getpass
p = getpass.getpass(prompt='digite a senha\n')
if p == '12345':
print('YO Paul')
else:
print('BRHHH')
print('O seu input foi:', p) # p = seu input
我收到这个警告:
Warning (from warnings module):
File "/usr/lib/python3.4/getpass.py", line 63
passwd = fallback_getpass(prompt, stream)
GetPassWarning: Can not control echo on the terminal. Warning: Password input may be echoed.
原文由 Paul Sigonoso 发布,翻译遵循 CC BY-SA 4.0 许可协议
Use an actual terminal – that is, an environment where
stdin
,stdout
andstderr
are connected to/dev/tty
, or another PTY-兼容设备。IDLE REPL 不满足这个要求。