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

yipeiwu_com6年前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的bit_length函数来二进制的位数方法

自Python3.1中,整数bit_length方法允许查询二进制的位数或长度。 常规做法: >>> bin(256) '0b100000000' >&g...

详解Python中find()方法的使用

 find()方法判断字符串str,如果起始索引beg和结束end索引能找到在字符串或字符串的一个子串中。 语法 以下是find()方法的语法: str.find(str,...

利用python计算windows全盘文件md5值的脚本

利用python计算windows全盘文件md5值的脚本

import hashlib import os import time import configparser import uuid def test_file_md5(fi...

关于tf.reverse_sequence()简述

tf.reverse_sequence()简述 在看bidirectional_dynamic_rnn()的源码的时候,看到了代码中有调用 reverse_sequence()这一方法,...

python实现计算倒数的方法

本文实例讲述了python实现计算倒数的方法。分享给大家供大家参考。具体如下: class Expr: def __add__(self, other): return P...