【问题标题】:Getting password using getPass isn't working for me [duplicate]使用 getPass 获取密码对我不起作用 [重复]
【发布时间】:2020-10-28 23:53:19
【问题描述】:

我的代码:

from getpass import getpass
def display_credentials():
    website = input("Enter the name of the website:")
    password = getpass("Enter master password: ")
    print(website)
    print(password)

if __name__ == "__main__":
    display_credentials()

输出: 输入网站名称:yahoo

问题: 下一行根本不会被执行。不知道这里有什么错误。 我希望在输入网站名称后执行下一行(询问密码)。

【问题讨论】:

  • 为我工作.....
  • 你是如何运行这个的?什么操作系统/控制台/终端?
  • 我正在使用pycharm运行代码

标签: python python-3.x input passwords getpass


【解决方案1】:

它在控制台中工作。

您遇到的问题可能是您通过 PyCharm 或任何其他 IDE 启动它,它有自己的控制台(而不是 getpass 使用的控制台)

通过命令提示符运行代码应该可以工作

【讨论】:

  • 谢谢!是的,当我通过命令提示符运行代码时,它运行良好。
猜你喜欢
  • 2012-09-16
  • 2011-08-03
  • 1970-01-01
  • 2015-06-08
  • 2016-11-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多