我收到以下代碼的錯誤。如何解決它?python中的列表()錯誤
代碼:
a= list(set([1,2,3,4]))
print(a)
錯誤:
TypeError Traceback (most recent call last)
<ipython-input-118-e8b21f19c16c> in <module>()
----> 1 a= list(set([1,2,3,4]))
2 print(a)
TypeError: 'list' object is not callable
你以前在代碼中的任何位置定義過'list'變量嗎?因爲該線路有效,並且應該爲我工作。 – Chinny84
嗯......如果'print'引發了'TypeError'(因爲堆棧跟蹤中的2是'print(a)'),那麼在你的代碼的某處你做了這樣的事情:'print = [1,2, 3]'將'print'重新定義爲'list' – abccd
歡迎來到SO。請花時間閱讀[問]及其中包含的鏈接。感謝您在問題中包含Traceback。 – wwii