getpass不起作用


#! /usr/bin/env python
# -*- coding:utf-8 -*-

# login 模塊中登錄時輸入密碼,想用getPass模塊實現密碼的不回顯操作。
#如下:
import getpass
ret = input("welcome to the system:please make a choice-1 or 2")
if ret == '1':
    user = input("請輸入用戶名:")
    pwd = getpass.getpass("請輸入密碼:")

  


#結果:
#在pycharm中根本不起作用,用官方帶的IDLE顯示如下:
"""
welcome to the system:please make a choice-1 or 21
請輸入用戶名:wuwuwu

Warning (from warnings module):
File "C:\Program Files\Python36\lib\getpass.py", line 100
return fallback_getpass(prompt, stream)
GetPassWarning: Can not control echo on the terminal.
Warning: Password input may be echoed.
請輸入密碼:123456
用戶名不存在
>>>
"""

# 命令行界面中測試可行,getpass模塊只能用於命令行界面!
# stack overflow 上 有大神如是說:
"""
Use an actual terminal -- that is, an environment where stdin,
stdout and stderr are connected to /dev/tty, or another PTY-compliant device.

The IDLE REPL does not meet this requirement.
"""



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM