Mã nguồn: lib/getpass.py Lib/getpass.py
Tính khả dụng: Không phải emscripten, không phải wasi.: not Emscripten, not WASI.
Mô -đun này không hoạt động hoặc không có sẵn trên các nền tảng Webassugging wasm32-emscripten
và wasm32-wasi
. Xem các nền tảng Webassugging để biết thêm thông tin.WebAssembly platforms for more information.
Mô -đun getpass
cung cấp hai chức năng:
Nhắc người dùng cho mật khẩu mà không lặp lại. Người dùng được nhắc sử dụng dấu nhắc chuỗi, mặc định là 'Password: '
. Trên Unix, lời nhắc được ghi vào luồng đối tượng giống như tệp bằng cách sử dụng trình xử lý lỗi thay thế nếu cần. luồng mặc định cho thiết bị đầu cuối kiểm soát [/dev/tty
] hoặc nếu điều đó không có sẵn đối với sys.stderr
[đối số này bị bỏ qua trên Windows].
Nếu đầu vào miễn phí của Echo không có sẵn getPass [] sẽ quay lại để in một thông báo cảnh báo để truyền phát và đọc từ sys.stdin
và phát hành ____10.
Ghi chú
Nếu bạn gọi GetPass từ bên trong Idle, đầu vào có thể được thực hiện trong thiết bị đầu cuối bạn đã khởi chạy Idle từ thay vì chính cửa sổ nhàn rỗi.
ExceptiongetPass.getPasswarning¶ getpass.GetPassWarning¶Một lớp con
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!1 được cấp khi đầu vào mật khẩu có thể được lặp lại. getPass.getUser []getuser[]¶
Trả về tên đăng nhập của người dùng.
Hàm này kiểm tra các biến môi trường
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!2,
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!3,
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!4 và
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!5, theo thứ tự và trả về giá trị của mã đầu tiên được đặt thành chuỗi không trống. Nếu không được đặt, tên đăng nhập từ cơ sở dữ liệu mật khẩu được trả về trên các hệ thống hỗ trợ mô -đun
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!6, nếu không, một ngoại lệ sẽ được nêu ra.
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!2,
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!3,
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!4 and
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!5, 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 the
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!6 module, otherwise, an exception is raised.
Nói chung, chức năng này nên được ưu tiên hơn
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!7.
getPass [] nhắc người dùng cho mật khẩu mà không lặp lại. Mô -đun GetPass cung cấp một cách an toàn để xử lý các lời nhắc mật khẩu nơi các chương trình tương tác với người dùng thông qua thiết bị đầu cuối.
Mô -đun GetPass cung cấp hai chức năng:
Sử dụng hàm getPass [] để nhắc mật khẩu người dùng function to prompt user password
Cú pháp: getPass.getPass [nhắc nhở = mật khẩu: ‘, stream = none] & nbsp;getpass.getpass[prompt=’Password: ‘, stream=None]
Hàm getPass [] được sử dụng để nhắc cho người dùng sử dụng dấu nhắc chuỗi và đọc đầu vào từ người dùng làm mật khẩu. Đầu vào đọc mặc định cho mật khẩu của người dùng: Được trả lại cho người gọi dưới dạng chuỗi.
Ví dụ 1: Không có lời nhắc được cung cấp bởi người gọi & nbsp;No Prompt provided by the caller
Ở đây, không có lời nhắc được cung cấp bởi người gọi. Vì vậy, nó được đặt thành lời nhắc mặc định mật khẩu mật khẩu. & NBSP;
Python
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!8
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!9
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.0
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
'Password: '
8
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
/dev/tty
0/dev/tty
1 /dev/tty
2
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.2
/dev/tty
5$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
wasm32-emscripten
3
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.2
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.9
wasm32-emscripten
0wasm32-emscripten
8wasm32-emscripten
9Đầu ra: & nbsp;
$ python3 getpass_example1.py Password: ['Password entered:', 'aditi']
Có phải thư viện Python tiêu chuẩn GetPass? Security Question
Khoa học dữ liệu thực tế sử dụng Python Có hai chức năng được xác định trong mô -đun GetPass của Thư viện tiêu chuẩn của Python. Chúng rất hữu ích bất cứ khi nào một ứng dụng dựa trên thiết bị đầu cuối chỉ cần được thực thi sau khi xác thực thông tin đăng nhập của người dùng.
Python
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!8
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!9
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.3
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
wasm32-wasi
4$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
wasm32-wasi
6wasm32-wasi
7wasm32-wasi
8 wasm32-wasi
9
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
getpass
2$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.2
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.9
wasm32-emscripten
0getpass
7wasm32-wasi
7wasm32-emscripten
3
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.2
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.9
wasm32-emscripten
0'Password: '
4wasm32-wasi
7Đầu ra: & nbsp; & nbsp;
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!
Sử dụng getUser [] & nbsp; hàm để hiển thị tên người dùng function for displaying username
Cú pháp: getpass.getUser []getpass.getuser[]
Hàm getUser [] hiển thị tên đăng nhập của người dùng. Hàm này kiểm tra các biến môi trường logname, người dùng, lname và tên người dùng, theo thứ tự và trả về giá trị của chuỗi không trống đầu tiên. & Nbsp;
Python
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!8
$ python3 getpass_example2.py Your favorite flower? Welcome..!!! $ python3 getpass_example2.py Your favorite flower? The answer entered by you is incorrect..!!!9
'Password: '
8
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
/dev/tty
0/dev/tty
1 /dev/tty
2
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.2
/dev/tty
5$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.2
wasm32-wasi
8 /dev/tty
5$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.4
sys.stderr
6$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
sys.stderr
8
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.9
sys.stdin
0sys.stderr
8sys.stdin
2
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.2
wasm32-emscripten
3$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.1
sys.stderr
8
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.9
sys.stdin
8Đầu ra: & nbsp;
$ python3 getpass_example3.py User Name : bot Welcome!!! $ python3 getpass_example3.py User Name : bot The password you entered is incorrect.