首页 > 解决方案 > 将列表附加到另一个列表中。'str' 对象没有属性 'append' 发生错误

问题描述

我创建了一个列表grapsedParts:

graspedParts = []

pickInfo = [robo.ActiveTool, part]

graspedParts.append(pickInfo)

但由于某种原因,它将被抓住的部分视为字符串而不是列表。它不断返回

AttributeError:“str”对象没有属性“append”

我用谷歌搜索了这个错误,并明白一个不能附加到一个 str 但我看不出我哪里出错了。任何帮助将不胜感激谢谢。

标签: pythonlistappendnested-lists

解决方案


尝试将 grabedParts 更改为列表,即

graspedParts = list()

推荐阅读