当我运行这段代码时:
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.
getpass
的工作原理:https://dev59.com/02445IYBdhLWcg3w9Oss - handlegetpass
并不适合在这种环境中使用。 - PM 2Ring