问题
Hey all just started dabbling in a little Python to help out with a few scripts at work, but I seem to be getting hung up on a little issue.
I am using Eclipse with pydev for my development platform and developing against python 2.7.3. I am just trying to prompt a user for their password, using:
password = getpass.getpass()
That line works as expected when running in the terminal/command prompt, however when I am running in the Eclipse console, the user's input isn't hidden like it should be. Any ideas how to fix this?
回答1:
This is documented behaviour - some terminals are not capable of echo-free input, in that case, it should give a warning instead:
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.
From the docs for getpass.getpass().
来源:https://stackoverflow.com/questions/15668607/getpass-echoing-password-in-eclipse