本文介绍了如何在 PyCharm 中使用 Python getpass.getpass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现 getpass 在 PyCharm 中不起作用.它只是挂起.

I have found getpass does not work in PyCharm. It just hangs.

实际上似乎 msvcrt.getch 和 raw_input 也不起作用,所以问题可能不在于 getpass.而是使用 PyCharm 的 stdio 处理的i"位.

In fact is seems msvcrt.getch and raw_input also don't work, so perhaps the issue is not with getpass. Instead with the 'i' bit of PyCharm's stdio handling.

问题是,我无法将我的个人密码放入代码中,因为它最终会出现在其他人可以看到的 SVN 中.所以我每次都使用 getpass 来获取我的密码.

The problem is, I can't put my personal password into code as it would end up in SVN which would be visible to other people. So I use getpass to get my password each time.

在搜索中,我只能找到Pycharm 进行圆顶黑客攻击以让 Django 使用 getpass"但没有暗示该黑客攻击是什么......

On searching, all I can find is that "Pycharm does dome hacking to get Django working with getpass" but no hint as to what that hack is....

我看过 getpass,它在 Windows 上使用 msvcrt(所以这个问题可能只在 Windows 上)

I've looked at getpass and it uses msvcrt on Windows (so this problem might only be on Windows)

我的问题是:是否有解决此问题的方法?

My question is: Is there a workround for this issue?

推荐答案

For PyCharm 2018.3

转到编辑配置",然后选择在输出控制台中模拟终端".

For PyCharm 2018.3

Go to 'Edit Configurations' and then select 'Emulate terminal in output console'.

这篇关于如何在 PyCharm 中使用 Python getpass.getpass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 00:22