简体   繁体   中英

They give me this type error "sequence item 0: expected str instance, NoneType found" for my codes

from tkinter import*
import string
import random

win = Tk()
win.geometry("500x400")
win.title("password generator")

def password_generator():
    character = list(string.ascii_letters + string.digits + "@#$&^!%")
    random.shuffle(character)
    
    password =[]
    password_length = 7
    
    for x in range(password_length):
        password.append(random.shuffle(character))
        
    random.shuffle(password)
    password= "".join(password)
    pass_word_l.configure(password)
    

u_name = Label(win, text="Usename:", font="arial,20").place(x=70, y=100)
pass_word = Label(win, text="Password:", font="arial,20").place(x=70, y=160)

u_name_e = Entry(win, width=30).place(x=170, y=100)
pass_word_l = Label(win, font=("arial", 13,"bold")).place(x=170, y=160)

G_pass = Button(win, text="Generate Password", width=20, borderwidth=5, command=password_generator).place(x=190,y=220 )

win.mainloop()

I tried creating a password generator but when i run the codes they gave me this type error: "sequence item 0: expected str instance, NoneType found", and i can't identify my mistake

You are getting an error. Because you left out keyword text=from configure in line 21. I including comment from @John Gordon.

from tkinter import*
import string
import random

win = Tk()
win.geometry("500x400")
win.title("password generator")

def password_generator():
    character = list(string.ascii_letters + string.digits + "@#$&^!%")
    random.shuffle(character)
    
    password =[]
    password_length = 7
    
    for x in range(password_length):
        password.append(random.choice(character))
        
    random.shuffle(password)
    password= "".join(password)
    pass_word_l.configure(text=password)
    

u_name = Label(win, text="Usename:", font="arial,20").place(x=70, y=100)
pass_word = Label(win, text="Password:", font="arial,20").place(x=70, y=160)

u_name_e = Entry(win, width=30).place(x=170, y=100)
pass_word_l = Label(win, font=("arial", 13,"bold"))
pass_word_l.place(x=170, y=160)

G_pass = Button(win, text="Generate Password", width=20, borderwidth=5, command=password_generator).place(x=190,y=220 )

win.mainloop()

Screenshot:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM