Can i get console input without echo in python?

前端 未结 3 1668
迷失自我
迷失自我 2020-12-05 13:04

Can I get console input without echo in python?

相关标签:
3条回答
  • 2020-12-05 13:31

    There is also another solution (at least on unix systems, I don't know if this is working on Windows). Simply switch off the console output and use raw_input:

    os.system("stty -echo")
    password = raw_input('Enter Password:')
    os.system("stty echo")
    print "\n"
    
    0 讨论(0)
  • 2020-12-05 13:35

    Use getpass:

    >>> from getpass import getpass
    >>> getpass()
    Password:
    'secret'
    
    0 讨论(0)
  • 2020-12-05 13:38

    Maybe the 'console' module is your only bet (it's kinda 'fork' of the curses module for Unix), however I haven't seen anything related to terminal echo disabling in its homepage, you might try to dig into it by yourself.

    0 讨论(0)
提交回复
热议问题