想要输出类似于”A112“的字符串所代表的储物架位置,但是发现函数无法使用
from tkinter import *
from tkinter import messagebox
text1=r=''
x=5
window = Tk()
window.title("First Window")
window.geometry("350x200")
lbl = Label(window, text="Hello")
lbl.grid(column=0, row=0)
txt = Entry(window, width=10)
txt.grid(column=1, row=0)
txt2=Label(window, text="output")
txt2.grid(column=1, row=1)
def searching():
for i in range(r):
south=["Z","Y","X","W","V","U","T","S","R","Q","P","O","M","N","L","K","J",]
middle=["H"]
north=["A","B","C","D","E","F","G"]
x=input("请输入序列号(斜杠前字母大写)")
a1=x[0]
a2=x[1]
if a1=='G':
if '5' >= a2 >='0':
text3 = "北架"
txt2.configure(text=text3)
else:
text3="中架"
txt2.configure(text=text3)
elif a1=='I':
text3='人工操作'
txt2.configure(text=text3)
elif a1 in south:
text3="南架"
txt2.configure(text=text3)
elif a1 in middle:
text3="中架"
txt2.configure(text=text3)
elif a1 in north:
text3="北架"
txt2.configure(text=text3)
else:
text3="请再确认编号"
txt2.configure(text=text3)
btn = Button(window, text="searching", command=searching)
btn.grid(column=2, row=0)
window.mainloop()
调用之后就提示”TypeError: 'str' object cannot be interpreted as an integer“
希望有朋友能够提供帮助!