在Python中获取命令行密码输入 [英] Getting command-line password input in Python

查看:433
本文介绍了在Python中获取命令行密码输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道如何在Linux中,当你尝试一些Sudo的东西,它告诉你输入密码,并在你键入,没有显示在终端窗口(密码没有显示)?

You know how in Linux when you try some Sudo stuff it tells you to enter the password and, as you type, nothing is shown in the terminal window (the password is not shown)?

有没有办法在Python?我正在编写一个脚本,需要这么敏感的信息,并希望它在我打字时被隐藏。

Is there a way to do that in Python? I'm working on a script that requires so sensitive info and would like for it to be hidden when I'm typing it.

换句话说,我想从用户那里获取密码,而不显示密码。

In other words, I want to get the password from the user without showing the password.

谢谢。

推荐答案

使用 getpass.getpass()

这篇关于在Python中获取命令行密码输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆