How do I convert a password into asterisks while it is being entered?

前端 未结 9 1949
感情败类
感情败类 2020-11-28 13:31

Is there a way in Python to convert characters as they are being entered by the user to asterisks, like it can be seen on many websites?

For example, if an email use

相关标签:
9条回答
  • 2020-11-28 14:14

    first install these two library

    pip install getpass 
    pip install stdiomask
    

    note that you install std io mask not studiomask .....

    and then the code is

    password = stdiomask.getpass() # It will ask to enter password and display * on the screen
    
    print(password)
    

    This is the solution output:

    Password: *****
    google
    
    0 讨论(0)
  • 2020-11-28 14:16

    while using getpass in python, nothing is indicated to show a password input.

    this can be resolved by this simple solution:

    just copy the ‘getpass_ak.py’ module provided in the link to python’s Lib folder.

    https://starrernet.wixsite.com/analytix/python-coder

    use the following code:

    import getpass_ak
    
    a = (getpass_ak.getpass('password: '))
    

    this will add * to your password inputs.

    0 讨论(0)
  • 2020-11-28 14:23

    There is getpass(), a function which hides the user input.

    import getpass
    
    password = getpass.getpass()
    print(password)
    
    0 讨论(0)
提交回复
热议问题