从 IDLE 运行时出现“GetPassWarning:无法控制终端上的回显”

新手上路,请多包涵

当我运行这段代码时:

 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 许可协议

阅读 1.5k
2 个回答

Use an actual terminal – that is, an environment where stdin , stdout and stderr are connected to /dev/tty , or another PTY-兼容设备。

IDLE REPL 不满足这个要求。

原文由 Charles Duffy 发布,翻译遵循 CC BY-SA 3.0 许可协议

在终端而不是 IDE 中运行代码。你会看到那里没有更多的警告。要运行您的代码,请在终端中输入此命令:

 python3 your_program.py

原文由 Reyhaneh Trb 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题