'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'

 

posted on 2016-12-23 15:07  大大的橙子  阅读(787)  评论(0编辑  收藏  举报

导航