python实现在控制台输入密码不显示的方法

yipeiwu_com5年前Python基础

本文实例讲述了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程序设计有所帮助。

相关文章

Python之Numpy的超实用基础详细教程

Numpy在python中属于非常常用的包,无论是机器学习搭配pandas,还是数据可视化搭配pylab都是很正常的搭配。 Numpy numpy的官方中文文档:NumPy 中文 Nu...

浅析pandas 数据结构中的DataFrame

浅析pandas 数据结构中的DataFrame

DataFrame 类型类似于数据库表结构的数据结构,其含有行索引和列索引,可以将DataFrame 想成是由相同索引的Series组成的Dict类型。在其底层是通过二维以及一维的数据块...

python3实现绘制二维点图

python3实现绘制二维点图

如下所示: import matplotlib.pyplot as plt plt.plot([1,2,3],[4,5,6],'ro') plt.show()#这个智障的编辑器,,,...

pytorch常见的Tensor类型详解

Tensor有不同的数据类型,每种类型分别有对应CPU和GPU版本(HalfTensor除外)。默认的Tensor是FloatTensor,可通过torch.set_default_te...

python 读写excel文件操作示例【附源码下载】

本文实例讲述了python 读写excel文件操作。分享给大家供大家参考,具体如下: 对excel文件的操作,python有第三方的工具包支持,xlutils,在这个工具包中包含了xlr...