getpass模块

# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#getpass模块



import getpass
'''
>>> help(getpass)

FUNCTIONS
    getpass = win_getpass(prompt='Password: ', stream=None)
        Prompt for password with echo off, using Windows getch().
    
    getuser()
        Get the username from the environment or password database.
        
        First try various environment variables, then the password
        database.  This works on Windows as long as USERNAME is set.

DATA
    __all__ = ['getpass', 'getuser', 'GetPassWarning']
'''

#获得登陆的用户名
print  getpass.getuser()#Administrator


#getpass.getpass([prompt[, stream]]);prompt:为用户输入的提示字符串,默认为:Password:
print  getpass.getpass()#请输入密码
原文地址:https://www.cnblogs.com/dengyg200891/p/4932499.html