getpass --- Input kata sandi portabel¶
Kode sumber: Lib/getpass.py
Ketersediaan
This module does not work or is not available on WebAssembly platforms
wasm32-emscripten and wasm32-wasi. See
WebAssembly platforms for more information.
The getpass module provides two functions:
- getpass.getpass(prompt='Password: ', stream=None)¶
Meminta kata sandi kepada pengguna tanpa echo. Pengguna diminta menggunakan string prompt, yang secara default adalah
'Password: '. Pada Unix, prompt ditulis ke objek mirip-berkas stream menggunakan penangan galat replace jika diperlukan. stream secara default adalah terminal pengendali (/dev/tty) atau, jika terminal tersebut tidak tersedia,sys.stderr(argumen ini diabaikan pada Windows).If echo free input is unavailable getpass() falls back to printing a warning message to stream and reading from
sys.stdinand issuing aGetPassWarning.Catatan
If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself.
- exception getpass.GetPassWarning¶
Subkelas
UserWarningyang dimunculkan ketika input kata sandi mungkin di-echo.
- getpass.getuser()¶
Mengembalikan "nama login" pengguna.
This function checks the environment variables
LOGNAME,USER,LNAMEandUSERNAME, in order, and returns the 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 support thepwdmodule, otherwise, an exception is raised.Secara umum, fungsi ini sebaiknya lebih dipilih daripada
os.getlogin().