![](/img/trans.png)
[英]"TypeError: 'str' object is not callable" while using scrapy
[英]'str' object is not callable using enumerate
我正在嘗試執行以下操作:
for index, image_properties in enumerate(list_of_properties):
index = str(index)
但我不斷
TypeError at /
'str' object is not callable
這是怎么了?
正如評論者所提到的,您必須在某處定義str
,並且它會覆蓋str
內置函數。
在Python中,您可以像這樣輕松地“重新綁定”符號。 例如,請參閱此會話:
>>> str(2)
'2'
>>> def str(x): return x + 1
...
>>> str(2)
3
>>> str = 1
>>> str(2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
此外, 您的 TypeError
文本建議將str
定義為較早位置的字符串對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.