How to use the Python getpass.getpass in PyCharm

前端 未结 6 1162
醉话见心
醉话见心 2020-12-08 14:17

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

In fact is seems msvcrt.getch and raw_input also don\'t work, so perhaps the issue is not with getpass

6条回答
  •  情话喂你
    2020-12-08 14:53

    A common solution to this would be to store the credentials in a file which you mark ignored by your VCS. Then just:

    with open('credentials.txt') as f:
        user, pw = f.read().split('\n')  # or similar
    

    Alternatively, have them specified in environment variables. Both of these methods should work around PyCharm's handling of stdin.

提交回复
热议问题