简体   繁体   English

是否可以将用户输入隐藏为“sudo”密码输入?

[英]Is it possible to make user input invisible as a 'sudo' password input?

I'm using raw_input() to receive password from user in interactive mode, but I want to make input symbols invisible for security reasons, as it is when you're typing your password using sudo or connecting to a database. 我正在使用raw_input()以交互模式从用户接收密码,但出于安全原因,我想使输入符号不可见,就像您使用sudo键入密码或连接到数据库时一样。 How I should do it? 我应该怎么做?

You need the getpass module. 你需要getpass模块。

from getpass import getpass
password = getpass()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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