Follow dba-ninja.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

dba-ninja.com Links

Dba_db2_button

Sqlserver_dba_button

How to hide user input for password in Python

15 January,2022 by Rambler

Question: How do I hide user input for a password entry using Python?   So instead of  the password displaying as the user types the password , the screen wouldn't change.

Answer: There is the getpass() function , which comes as standard part of the Python Library . From the Python documentation:  "Prompt the user for a password without echoing. The user is prompted using the string prompt, which defaults to 'Password: '"

import getpass

password = getpass.getpass()
print(password)


Author: Rambler (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to hide user input for password in Python


dba-ninja.com