I'm writing a basic python program to show if a pre-set username and password are correct. I have used raw_input for the username and getpass for the password inputs. I was wondering if it would be possible to have a star or dot show up in the password field every time a character is typed. I'm using python 2.7 as well, so please specify if I need python 3 for any of your suggestions.
Asked
Active
Viewed 3,587 times
-1
-
1Do note that not echoing anything at all (ie the way [getpass](http://pymotw.com/2/getpass/) works) is the standard for command-line apps. I would find astericks very odd. – NightShadeQueen Aug 11 '15 at 18:55
-
You probably want the curses library, if you were open to a gui it is very simple to do it with Tkinter – Padraic Cunningham Aug 11 '15 at 18:57
1 Answers
-2
Use getpass instead of raw_input
import getpass
p = getpass.getpass()
Password:
print(p)
blah

Chris Montanaro
- 16,948
- 4
- 20
- 29
-
This doesn't answer the OP's question. They asked for an asterik (*) to be typed out instead of the user's input. This will print nothing to the command-line. – michaelpri Aug 12 '15 at 06:24