相关疑难解决方法(0)

python QTconsole 的数据隐藏

目前我正在制作一个图像身份验证项目,其中我需要借助密钥来验证图像。raw_input我通过 IPython 控制台从用户处获取密钥。我想隐藏正在输入的密钥。

预期结果:

Enter the key = *****或者Enter the key = (nothing shown)

我找到了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
Run Code Online (Sandbox Code Playgroud)

但这会在显示屏上打印无限数量的星号。

请让我知道这个问题的一些解决方案。

python spyder qtconsole anaconda

5
推荐指数
0
解决办法
1604
查看次数

标签 统计

anaconda ×1

python ×1

qtconsole ×1

spyder ×1