当我运行此代码时:
def printPredictions(matches):
pPredictionTable = PrettyTable()
pPredictionTable.field_names = ["Player 1", "Player 2", "Difference", "Winner"]
for match in matches:
p1 = match['teamA']
p2 = match['teamB']
if match['aBeatb'] == True:
pPredictionTable.add_row([match['teamA'], match['teamB'], match['difference'], p1])
else:
pPredictionTable.add_row([match['teamA'], match['teamB'], match['difference'], p2])
print(pPredictionTable)
printPredictions(pmatches)
我得到这个错误:
Traceback (most recent call last):
File "C:\Users\ericr_000\Desktop\PyDev\NPA-2-Rating-System\Rankings.py", line 645, in <module>
printPredictions()
TypeError: 'str' object is not callable
我有pmatches作为一个单独的字典,我没有编码技能来解决这个问题。(第145行是printPredictions(pmatches)
如果您在尝试调用
printPredictions
时得到'str' object is not callable
,这意味着当程序到达第645行时,printPredictions
的名称被重新分配给一个字符串。在代码的某个地方您应该为该变量选择一个不同的名称,或者完全删除该行。你知道吗
相关问题 更多 >
编程相关推荐