首页 > 解决方案 > TypeError:'str'对象不是可调用的带有变量的python

问题描述

我有变量a

a = 349

我可以float(a)

输出是:

349.0

我可以int(a)

输出是:

349

str(a)我有错误

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-152-bddfa438ffc2> in <module>
----> 1 str(a)

TypeError: 'str' object is not callable

为什么?str 是我所知道的基本方法。我做错了什么

标签: python

解决方案


编码:

a = 349
a = int(a)
a = float(a)
str(a)

在 jupyter 和终端 repl 中工作。

str = 'whatever xyz'您是否在代码中的某处命名了另一个变量?


推荐阅读