The Python module is based on the Getpass module (Pycharm is not available.) )

Source: Internet
Author: User

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.) )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.