第四行指定形参win.config(bg= 'red')
写成background="red"试试
from tkinter import Tk win = Tk() win.title('aaa') win.config(cnf={'bg': 'red'}) win.mainloop()