见下相关代码:
def opencommand():
number=entry1.get()
mydata = csv.reader(open('result.csv','rU'))
card_name = []
for row in mydata:
card_name.append(row[9])
r=0
while r<number:
randomnumbers=[]
counter=0
while counter<5:
randomnumbers.append(randint(1,90))
counter=counter+1
pack1=[]
p=0
while p<5:
pack1.append(card_name[randomnumbers[p]])
p=p+1
print pack1
r=r+1
和....
numpac = Label(options_frame,text='Number of Packs')
entry1 = Entry(options_frame)
numpac.grid(row=0,column=0,sticky=E)
entry1.grid(row=0,column=1)
openbutton = Button(options_frame, text='Open',command=opencommand)
openbutton.grid(row=1,column=0,columnspan=2)
任何人都可以告诉我为什么当我包含get部分它冻结但如果我将它设置为固定数字我不会?
下面是一些文字,因为它说的是很多代码:vkjberbverihjbvjerhbvjhebvjhervhjberjvhberjhbverhjbvjlerbvjlerbvljerbverjlhbvrejlvhberljvhberljvhberljvbherjlvhberjvlhbevljerbvljerbvlerjhbvelrjbvlerjhbvlejrhbv答案 0 :(得分:2)
因为get()
返回一个字符串,而不是一个数字。你需要转换它:
number = int(entry1.get())