从 Tkinter 标签中移除 {}
remove {} from Tkinter label
import Tkinter
window=Tk()
msg1='abc'
msg2='def'
label =Label(window,text=(msg1,msg2), fg='blue')
label.grid(row=0,column=1)
window.mainloop()
输出为 {abc}{def}
我希望输出为 abcdef
。怎么做?
您正在编写 text=(msg1,msg2)
,(msg1,msg2)
是一个列表。
只需将其更改为 msg1+msg2
并且此代码无法运行,如果您这样导入 Tkinter,则无法创建 Tk()
。
将其更改为 from Tkinter import *
import Tkinter
window=Tk()
msg1='abc'
msg2='def'
label =Label(window,text=(msg1,msg2), fg='blue')
label.grid(row=0,column=1)
window.mainloop()
输出为 {abc}{def}
我希望输出为 abcdef
。怎么做?
您正在编写 text=(msg1,msg2)
,(msg1,msg2)
是一个列表。
只需将其更改为 msg1+msg2
并且此代码无法运行,如果您这样导入 Tkinter,则无法创建 Tk()
。
将其更改为 from Tkinter import *