Getpass module of the Python module
The Python module, which is a python file that ends with a. Py, contains Python object definitions and Python statements.
The Getpass module provides portable password input, including the following two functions:
1. Getpass.getpass () 2. Getpass.getuser ()
Getpass.getpass ()
1
Prompts the user to enter a password, the parameter prompt prompts the user to start the input, defaults to ' Password: '.
When you enter a password, you can use the Getpass method in the Getpass module if you want to be invisible. Cases:
1 # !/usr/bin/env python 2 # -*-coding:utf-8-*- 3 4 Import Getpass 5 6 pwd = Getpass.getpass ("input your password:")7 8print pwd
Getpass.getuser ()
The function returns the login user name, not the parameter.
The function checks the environment variables LOGNAME,USER,LNAME , and USERNAMEto return a non-empty string. If these variables are set to NULL, the user name will be obtained from the database that supports the password, otherwise it will trigger an exception that cannot be found by the user!
Note that this module is not available in Pycharm.
Getpass module of Python module