我从缺乏响应中猜测,没有一个干净整洁的解决方案。这是我所做的:
我因此创建了一个实用程序:
class Pybot_Utilities:
def sublistReplace(self, processList, item, SublistIndex, ItemIndex):
'''
Replaces an item in a sublist
Takes a list, an object, an index to the sublist, and an index to a location in the sublist inserts the object into a sublist of the list at the location specified.
So if the list STUFF is (X, Y, (A,B,C)) and you want to change B to FOO give these parameters: [STUFF, FOO, 2, 1]
'''
SublistIndex=int(SublistIndex)
ItemIndex=int(ItemIndex)
processList[SublistIndex][ItemIndex] = str(item)
return processList
然后我将此条目放入我的机器人框架测试套件文件中:
| | ${ListWithSublist} = | sublistReplace | ${ListWithSublist]} | NewItem | 1 | 1 |
(当然是导入我的实用程序库)
运行后,列表索引 1 处的子列表中的第二项(索引 1)将是“NewItem”
也许不是最优雅或最灵活的,但它现在可以完成这项工作