如何消除Label中的花括号(text =)

时间:2015-04-08 21:59:07

标签: python python-3.x tkinter label

如何消除周围的花括号"总共"和"字典中的条目"

enter image description here

self.status_bar = Label(self.status_bar, text=("There are total", len(dictionary_data), "entries in dictionary."), bg="yellow", relief=FLAT)

1 个答案:

答案 0 :(得分:4)

问题是您当前正在传递text参数的元组。相反,你应该传递一个字符串。您可以使用str.format将字典长度插入此字符串中:

self.status_bar = Label(self.status_bar, text="There are total {} entries in dictionary.".format(len(dictionary_data)), bg="yellow", relief=FLAT)