'Python: hiding input characters with Stars [duplicate]
I am requesting user input. I am asking for username then password. EG
username = input('Please enter a Username:\n')
password = input('Please enter a Password:\n')
When run this will of course appear like this:
Please enter a Username:
Iain
Please enter a Password:
Iain
What I want is this:
Please enter a Username:
Iain
Please enter a Password:
****
Solution 1:[1]
You can use a library called pwinput.
You can install it using pip: pip3 install pwinput.
And use it as follows:
import pwinput
password = pwinput.pwinput()
This would open a prompt like this:
Password: ****
If you want to remove the text 'Password:', you can do:
password = pwinput.pwinput(prompt='')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Agni |
