The Python Console accepts commands in Python that you write after the prompt. Accepting Input from Console User enters the values in the Console and that value is then used in the program as it was required. To take input from the user we make use of a built-in function input().
getch: Read a keypress and return the resulting character. Nothing is echoed to the console. This call will block if a keypress is not already available, but will not wait for Enter to be pressed.
There are two functions that can be used to read data or input from the user in python: raw_input() and input(). The results can be stored into a variable. raw_input() – It reads the input or command and returns a string. input() – Reads the input and returns a python type like list, tuple, int, etc.
Use getpass:
>>> from getpass import getpass
>>> getpass()
Password:
'secret'
There is also another solution (at least on unix systems, I don't know if this is working on Windows). Simply switch off the console output and use raw_input:
os.system("stty -echo")
password = raw_input('Enter Password:')
os.system("stty echo")
print "\n"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With