Getting a hidden password input Getting a hidden password input python python

Getting a hidden password input


Use getpass.getpass():

from getpass import getpasspassword = getpass()

An optional prompt can be passed as parameter; the default is "Password: ".

Note that this function requires a proper terminal, so it can turn off echoing of typed characters – see “GetPassWarning: Can not control echo on the terminal” when running from IDLE for further details.


import getpasspswd = getpass.getpass('Password:')

getpass works on Linux, Windows, and Mac.


Use getpass for this purpose.

getpass.getpass - Prompt the user for a password without echoing


matomo