本文实例讲述了python实现在控制台输入密码不显示的方法。分享给大家供大家参考。具体实现方法如下:
import console;
namespace console{
//控制台读取密码,并显示星号
getPassword = function(){
var tstr = {};
var input = kbRead(true);
while( input.wVirtualKeyCode != 0xD/*_VK_ENTER*/ ){
if( input.uChar.asciiChar ){
..table.push(tstr,input.uChar.asciiChar);
if( input.uChar.asciiChar > 0x80){
..table.push(tstr,kbRead(true).uChar.asciiChar);
}
..io.stdout.write("*");
}
input = kbRead(true);
}
..io.stdout.write('\n');
return ..string.pack(tstr);
}
}
io.open();
io.stdout.write("请输入密码:");
var pwd = console.getPassword();
import win;
win.msgbox(pwd,"密码");
希望本文所述对大家的Python程序设计有所帮助。
当现有的脚本或服务需要将作用域化的仓库工作委托给 Claude Code 并以编程方式消费结构化响应时,请使用 Claude Agent SDK for Python。
Python免费学习笔记(深入):立即使用
在学习笔记中,你将探索 Python 的核心概念和高级技巧!










