在Python中获取命令行密码输入

编程入门 行业动态 更新时间:2024-10-28 06:22:13
本文介绍了在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中获取命令行密码输入

本文发布于:2023-10-25 18:42:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1527775.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令行   密码   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!