从IDLE运行时,"GetPassWarning:无法控制终端上的回显"

Pau*_*oso 7 python python-3.x

当我运行此代码时:

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
Run Code Online (Sandbox Code Playgroud)

我收到了这个警告:

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.
Run Code Online (Sandbox Code Playgroud)

Cha*_*ffy 9

使用一个实际的终端-也就是说,一个环境中stdin,stdoutstderr被连接到/dev/tty,或另一种标准的PTY装置.

IDLE REPL不符合此要求.


小智 5

在终端而不是 IDE 中运行代码。您会看到那里不再有警告。要运行代码,请在终端中输入以下命令:

python3 your_program.py
Run Code Online (Sandbox Code Playgroud)