所以我有这段代码:
from tkinter import *
import re
master = Tk()
e1 = Entry(master)
def confirmit():
s = re.findall(r'\b\d+\b', e1.get())
if e1.get() == "Whoscreator":
vyvod.configure(text="Kewbin")
if e1.get() == "Whatscreatorsrealname":
vyvod.configure(text="Peťo Letec")
if e1.get() == "/give " + (what should I type here?):
vyvod.configure(text= s)
vyvod = Label(master, text="First Name")
confirmer = Button(text="Confirm", command = confirmit)
e1.pack()
vyvod.pack()
confirmer.pack()
mainloop()
我有一个入口栏。
我想要这个例子:
如果我在栏中输入/give 1000
,它会在标签vyvod中输入数字1000
。我希望这适用于/give
答案 0 :(得分:0)
最简单的解决方案是将字符串拆分为空格,检查第一个单词,然后对其余单词做适当的处理。
value = e1.get()
first, rest = value.split(" ", 1)
if first == "/give":
vyvod.configure(text=rest)