문제

I am looking for an example of an instance where we import the Python getpass library, enter our password, and the password does not echo to the terminal.

Here is an example where it does echo the password to the terminal:

$ python
>>> import getpass
>>> getpass.GetPassWarning
<class 'getpass.GetPassWarning'>
>>> getpass.getpass(stream=None)
Password:
'hello'
>>> 

Can someone give an example where it does not echo to the terminal?

Thanks!

도움이 되었습니까?

해결책

You should write or save the password to a variable. Then the password will not be echoed. for example:

import getpass                                                                       

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

Enter the Password:

print (p)

Output on console: pass@123

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top