I’m writing a console program with Python under Windows.
The user need to login to use the program, when he input his password, I’d like they to be echoed as “*”, while I can get what the user input.
I found in the standard library a module called getpass, but it will not echo anything when you input(linux like).
Thanks.
I’m writing a console program with Python under Windows. The user need to login
Share
The
getpassmodule is written in Python. You could easily modify it to do this. In fact, here is a modified version ofgetpass.win_getpass()that you could just paste into your code:You might want to reconsider this, however. The Linux way is better; even just knowing the number of characters in a password is a significant hint to someone who wants to crack it.