Pregunta

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!

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top