簡體   English   中英

類型錯誤:不支持 + 的操作數類型:'function' 和 'int'

[英]TypeError: unsupported operand type(s) for +: 'function' and 'int'

為什么這個函數調用給我上面的錯誤?

count=0
def returncall():
  for i,j in enumerate(range(count,count+3),0):
    print i,j
  return j
count=returncall
print count()

問題在這里:

for i,j in enumerate(range(count,count+3),0):

countreturncall另一個名稱,因為您已經完成了count = returncall returncall是一個函數; 實際上,這正是語句所在的函數。您不能將整數添加到函數 ( count+3 ) 中,因為那毫無意義。

我真的不明白你在這里試圖做什么,所以不能真正提供進一步的建議。 但這就是錯誤消息的含義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM