python getpass模块简析

验证场景:python3.6

getpass是python内置的获取密码及用户名的模块,pycharm暂不支持该模块,可以用pycharm编辑程序,然后通过IDE或命令行执行。

getpass包含以下两个函数:

    getpass = win_getpass(prompt='Password: ', stream=None)
        Prompt for password with echo off, using Windows getch().
#提示用户输入密码,输入的密码将不会明文展示,prompt参数指定“输入提示"。

输入:>>> password=getpass.getpass(prompt='密码:') 

输出:密码:

    getuser()
        Get the username from the environment or password database.

#获取用户名,通过查询系统环境变量获取username,很少使用到。

你可能感兴趣的:(python自动化运维,getpass)