如何去掉Label(text=)中的花括号
How to eliminate curly braces in Label (text=)
如何消除 "There are total" 和 "entries in dictionary"
周围的大括号
self.status_bar = Label(self.status_bar, text=("There are total", len(dictionary_data), "entries in dictionary."), bg="yellow", relief=FLAT)
问题是您当前正在为 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)
如何消除 "There are total" 和 "entries in dictionary"
周围的大括号self.status_bar = Label(self.status_bar, text=("There are total", len(dictionary_data), "entries in dictionary."), bg="yellow", relief=FLAT)
问题是您当前正在为 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)