The Getpass module provides portable password input, including the following two functions:
1. Getpass.getpass ()
2. Getpass.getuser ()
Getpass.getpass ([prompt[, Stream]])
Prompts the user to enter a password, the parameter prompt prompts the user to start the input, defaults to ' Password: '. On Unix, the prompt is written to the class file object stream. The parameter stream defaults to the control terminal (/dev/tty) or to Sys.stderr when it is not available (this parameter is not valid on Windows).
If no echo input is unavailable, getpass () rolls back and outputs a warning message to the stream stream, reading from Sys.stdin and throwing an exception getpasswarning.
Applies To: Macintosh, Unix, Windows.
Note
If you call Getpass () in idle, the input may be done in the terminal where you start the idle and not in the idle window
1 >>> Import getpass2 >>> p=getpass.getpass (' Input your password ') 3 input your PASSWORD4 >>> PR Int (p) 5 AAA
exception Getpass. Getpasswarning
Python contains a subclass of exception Userwarning that is thrown when the password input may be echoed.
Getpass.getuser ()
Returns the user's login name for: Unix, Windows
The function sequentially detects the environment variables LOGNAME, USER, LNAME, and USERNAME, returning the first non-null value. If none of these variables are set, the system that supports the PWD module returns the login name in the password database, otherwise throws an exception.
Note that this module is not available in Pycharm.
The Python module is based on the Getpass module (Pycharm is not available.) )