為什么會報錯?我按答案寫的卻在python上報錯?2.7版本的
>>> L=[]
>>> x=1
>>> while x<=100:
? ? ? ? ? ? ? ?L.append(x*x)
? ? ? ? ? ? ? ?x=x+1
>>> print sum(L)
Traceback (most recent call last):
? File "<pyshell#106>", line 1, in <module>
? ? print sum(L)
TypeError: 'int' object is not callable
2017-11-17
?'int' object is not callable
2018-04-16
這個代碼沒有問題,你定義int類型的時候存在覆蓋、引用等操作;