如何从SelectionItem获取文本?遇AttributeError报错求助(OneLineAvatarListItem场景)
解决方法
- SelectionItem是列表项的包装对象,需先通过
content属性获取内部的OneLineAvatarListItem实例 - 再通过实例的
text属性获取文本,示例代码如下:
# 假设selected_item是获取到的SelectionItem实例 list_item = selected_item.content item_text = list_item.text
- 如果上述方法无效,可直接访问内部的文本控件获取内容:
item_text = list_item.primary_text.text
内容的提问来源于stack exchange,提问作者ana iraqi
相关产品推荐
相关产品推荐

