无法在Pycharm中捕获密码

问题描述 投票:0回答:1

我编写了一个简单的程序来使用getpass从命令中捕获密码,但该程序正在挂起

我想抓住密码并显示它。

import getpass


class PasswordEnter:

    def enterPassword(self):
        while True:
            print("--------------")
            password = getpass.getpass(prompt='Enter Password: ', stream=None)
            if not password:
                continue
            else:
                print("Actual Password : ", password)
                break


if __name__ == '__main__':
    test = PasswordEnter();
    test.enterPassword()
python pycharm
1个回答
0
投票

Pycharm不直接允许捕获密码。我们必须告诉Pycharm表现得像一个终端。以下是以下步骤。

  1. 按两次Shift键
  2. 编写编辑配置。
  3. 选择“编辑配置”并选择您的程序。
  4. 选中“输出控制台中的模拟终端”复选框。
  5. 单击应用,然后按确定。现在运行程序。
© www.soinside.com 2019 - 2024. All rights reserved.