简体   繁体   中英

Python 2.7 - how to get input, but don't show keys entered

I want to make it so that I'm taking input

enterKey = raw_input("String here: ")

But that any keys entered are not displayed - it should just act as a pause of sorts in the script until Enter/Return is pressed and then it can proceed.

Use getpass .

import getpass
keys = getpass.getpass("String here: ")

getpass : Prompts use to enter keys but it don't displays it.

You can use it as An interactive CLI Python program, which requires entering of password.

import getpass
key = getpass.getpass("enter Key :")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM