'str' object is not callable

>>> b=str(11)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable

原因:定义变量的时候,随机使用str,所以就被覆盖了str函数。可以退出重进python或者del掉自定义str变量。

python中内置了很多的函数和类,在自己定义变量的时候,切记不要覆盖或者和他们的名字重复

>>> del str
>>> str(122)
'122'
原文地址:https://www.cnblogs.com/dadadechengzi/p/6214844.html