randsemiconclusion = [3234234, 234234, 23432]
wordstring = " "
liststr = list(wordstring)
for i in range(0, len(randsemiconclusion)):
aw = randsemiconclusion[i]
for j in range(0, 6):
aac = int(i*7 + j+1)
liststr[aac] = aw[j]
wordstring = ''.join(liststr)
print("Wordstring --> ", wordstring, " <--")
回溯:
追踪(最近一次呼叫最后一次):
liststr[aac] = aw[j]
TypeError:&#39; int&#39;对象不可订阅
(这只是真正代码的提取器)
我不确定为什么会得到TypeError
该程序应该提取列表中的数字并将它们放在一个字符串中,如下所示:
列表[12,23,32]
为:
122332
答案 0 :(得分:0)
您可以重写以下功能:
def concatenate_list_data(list):
result= ''
for element in list:
result += str(element)
return result
my_result = concatenate_list_data([1, 5, 12, 2]) # leads to 15122