Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何清除所有动态创建的项目的 KivyMD 列表?例子:
for x in range(10): item = OneLineListItem(text=str(x)) self.List.add_widget(item)
我们现在有一个包含 10 个项目的列表。我想创建一个函数来删除所有这些,使列表为空。是否有任何内部功能可以获得类似的东西?
试试list.clear()。这将删除列表中的所有元素。
list.clear()
a = [1,2,3] a.clear() a Out[4]: []