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

前端 未结 9 1979
感情败类
感情败类 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:07

    If you're using Tkinter: (this is Python 2.x. However, 3.x would be very similar)

    from Tkinter import Entry, Tk
    
    master = Tk()
    
    Password = Entry(master, bd=5, width=20, show="*")
    Password.pack()
    
    master.mainloop()
    

    In the shell, this is not possible. You can however write a function to store the entered text and report only a string of *'s when called. Kinda like this, which I did not write. I just Googled it.

提交回复
热议问题