目前我正在制作一个图像身份验证项目,其中我需要借助密钥来验证图像。我将钥匙作为raw_input
用户通过 IPython 控制台。我想隐藏正在输入的密钥。
预期结果:
Enter the key = *****
or Enter the key = (nothing shown)
I found getpass()
隐藏输入数据的方法,但它在我的电脑上发出以下警告:Warning: QtConsole does not support password mode, the text you type will be visible.
我什至看到了这段代码:
import sys
import msvcrt
passwor = ''
while True:
x = msvcrt.getch()
if x == '\r':
break
sys.stdout.write('*')
passwor +=x
print '\n'+passwor
但这会在显示屏上打印无限数量的星号。
请让我知道这个问题的一些解决方案。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)