python - 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 是我所知道的基本方法。我做错了什么
解决方案
编码:
a = 349
a = int(a)
a = float(a)
str(a)
在 jupyter 和终端 repl 中工作。
str = 'whatever xyz'
您是否在代码中的某处命名了另一个变量?
推荐阅读
- excel - 需要帮助来查找、使用 bat 文件移动/复制特定文件到新文件夹
- testing - 量角器测试失败,窗口太小
- r - R:应用于 nXm 矩阵的每一列,返回 n*n*m 数组
- java - 如何将 Json 转换为 java 中的集合?
- kotlin - Ktor 拦截器中的状态
- javascript - 我正在使用角度材料表可扩展行
- php - password_verify() 如何比较密码和散列密码?
- html - 如何在不影响其中的表单和按钮的情况下更改此 Bootstrap 4 卡的不透明度?
- java - 如何将数据从 Firebase 获取到哈希映射中?
- java - 从firebase检索数据后需要反转listview