如何在Visual Studio Code上的Python 3中使用getpass隐藏密码输入?

时间:2019-10-22 12:31:56

标签: python visual-studio-code getpass

以下代码段:

perl -wT
print "$_\n" for @INC;

在Visual Studio Code的集成Python控制台中运行时,会产生以下结果:

from getpass import getpass

username = input("Username: ")
password = getpass("Password: ")

因此,显示密码提示后我键入的任何内容。有什么办法可以在集成的VS Code终端中隐藏它吗?例如在正常命令提示符下运行时

Username: User
Warning: Password input may be echoed.
Password: hunter2

我得到以下输出:

python test.py

因此,正如预期的那样,在密码提示后我在此处输入的任何内容都不会显示。

0 个答案:

没有答案