【发布时间】:2017-12-09 16:22:32
【问题描述】:
这里的想法是能够接受用户输入,女巫是Main 并将其值洗牌并重新将其输入到Second 条目中,错误消息:x[i],x[j] = x [j], x[i]
TypeError: 'str' 对象不支持项目分配
from tkinter import *
import random
def randomize(a):
Second.delete(0 , 'end')
b = Main.get()
c = random.shuffle(b)
Second.insert(0 , c)
root = Tk()
Main = Entry(root)
Main.grid(row = 1,column = 0 , sticky = 'we')
Second = Entry(root)
Second.grid(row = 2 , column = 0 , sticky = 'we')
randombutton = Button(root , text = 'Randomize')
randombutton.grid(row = 3 , column = 0 , sticky = 'we')
randombutton.bind('<Button-1>' , randomize)
【问题讨论】:
-
能否修改您的问题以提供完整的追溯?
标签: string python-3.6