有一个多维的清单,不清晰的结构:修改递归函数的外部列表在Python
a=[[['123', '456'], ['789', '1011']], [['1213', '1415']], [['1617', '1819']]]
而且还有一个递归函数,其操作列表:
def get_The_Group_And_Rewrite_It(workingList):
if isinstance(workingList[0],str):
doSomething(workingList)
else:
for i in workingList:
get_The_Group_And_Rewrite_It(i)
通过时间get_The_Group_And_Rewrite_It()
应该得到一个列表,例如,['123','456']
,一旦得到它,doSomething
函数应该用整个列表中的['abc']
来重写它。
与format[str,str,...]
的其他列表相同。最后,我应该得到的东西像
a=[[['abc'], ['abc']], [['abc']], [['abc']]]
我看到它会在C++中很容易,使用*links
,但如何做到这一点在Python?
不要做定期的作业,因为这样你失去原来的对象。就这样。 –