python在2d数组中增加值

2024-06-16 12:22:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要能够增加其中一个元素的值,但我不断得到错误,任何人都可以帮助

Table = {56:[12],54:[9],58:[9],4:[8],16:[8],20:[8],
             49:[8],1:[7],2:[7],11:[7],14:[7],25:[7],
             30:[7],35:[7],36:[7],41:[7],50:[7],52:[7],
             55:[7],59:[7],18:[6],21:[6],27:[6],42:[6],
             45:[6],6:[5],7:[5],13:[5],17:[5],29:[5],32:[5],
             34:[5],37:[5],44:[5],47:[5],5:[4],8:[4],10:[4],
             15:[4],24:[4],43:[4],46:[4],51:[4],3:[3],12:[3],
             19:[3],22:[3],23:[3],26:[3],38:[3],39:[3],40:[3],
             53:[3],9:[2],28:[2],31:[2],33:[2],57:[2],48:[1]}


print(str(Table[1]))
x = Table[1]
Table[1]= [x+1]
print(str(Table[1]))




[7]
Traceback (most recent call last):
  File "N:\CS Predictive algorithm\CS Predictive algorithm\CodeRelated\test.py", line 14, in <module>
    Table[1]= [x+1]
TypeError: can only concatenate list (not "int") to list

Tags: 元素most错误tablecallcsalgorithmlist