Movatterモバイル変換


[0]ホーム

URL:


Navigation

16.10.getpass — Portable password input

Thegetpass module provides two functions:

getpass.getpass(prompt='Password: ',stream=None)

Prompt the user for a password without echoing. The user is prompted usingthe stringprompt, which defaults to'Password:'. On Unix, the promptis written to the file-like objectstream.stream defaults to thecontrolling terminal (/dev/tty) or if that is unavailable tosys.stderr (this argument is ignored on Windows).

If echo free input is unavailable getpass() falls back to printinga warning message tostream and reading fromsys.stdin andissuing aGetPassWarning.

Availability: Macintosh, Unix, Windows.

Note

If you call getpass from within IDLE, the input may be done in theterminal you launched IDLE from rather than the idle window itself.

exceptiongetpass.GetPassWarning

AUserWarning subclass issued when password input may be echoed.

getpass.getuser()

Return the “login name” of the user. Availability: Unix, Windows.

This function checks the environment variablesLOGNAME,USER,LNAME andUSERNAME, in order, and returnsthe value of the first one which is set to a non-empty string. If none are set,the login name from the password database is returned on systems which supportthepwd module, otherwise, an exception is raised.

Previous topic

16.9.logging.handlers — Logging handlers

Next topic

16.11.curses — Terminal handling for character-cell displays

This Page

Quick search

Enter search terms or a module, class or function name.

Navigation

©Copyright 1990-2017, Python Software Foundation.
The Python Software Foundation is a non-profit corporation.Please donate.
Last updated on Sep 19, 2017.Found a bug?
Created usingSphinx 1.2.

[8]ページ先頭

©2009-2025 Movatter.jp