In python, enter a password on the console and do not display the password.
This example describes how to enter a password not to display in the python console. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
Import console; Namespace console { // The Console reads the password and displays the asterisk 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 ("enter the password :"); Var pwd = console. getPassword (); Import win; Win. msgbox (pwd, "password "); |
I hope this article will help you with Python programming.