python getpass密码输入带星号

pre*_*lpi 5 python python-2.7

如何在python中使用getpass模块输入密码时获得星号?

实际结果:

import getpass                                                                       

p=getpass.getpass("Enter the Password:")

Enter the Password:

print (p)

Output: password
Run Code Online (Sandbox Code Playgroud)

期待结果:

import getpass                                                                       

p=getpass.getpass("Enter the Password:")

Enter the Password:********

print (p)

Output: password
Run Code Online (Sandbox Code Playgroud)

Python 版本:2.7