python - Getpass 输入 Python 3

标签 python

我正在尝试创建密码输入。我知道 getpass.getpass,但是当我将它置于空闲状态时,它通过了一个错误提示“密码可能被回显”。

我的代码:

import getpass

p = getpass.getpass()

print("You entered:") + p

这可能行不通,因为我使用的是 Python 3.2.3

最佳答案

来自getpass文档:

Note If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself.

还有:

If echo free input is unavailable getpass() falls back to printing a warning message to stream and reading from sys.stdin and issuing a GetPassWarning.

所以您可能只是在 IDLE 环境中没有可用的echo free input(例如,您没有从 shell 启动它)。

关于python - Getpass 输入 Python 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34396842/

相关文章:

python - PO 中的 OpenERP V7 自定义

python - 在 Wagtail 的代码片段中使用 StreamField

python - 如何通过命令提示符导入 python 文件?

python - 计算字符串列表中的特定单个字母

python - 如何在Python中逐个复制输入文件ch并使用格式?

Python MySQL,这是准备好的语句吗?

python - Django 表单不会覆盖以前的条目

python - python的代码文档

python - tensorflow 量化: Array output does not have MinMax information

python - 有没有办法将参数传递给xml?或者修改一下?