python报错'str' object is not callable
>>> x=1.235
>>> int(x)
1
>>> str="fsgavfdbafdbntsbgbt"
>>> len(str)
19
>>>
>>> x=987456123
>>> str(x)
会报错'str' object is not callable。
str()是系统自带的,你不能在用它的时候自己同时定义一个别的叫做str的变量,这样会冲突。
把自定义的str变量改成了别的名字,str1,代码就通过了。
在Python中,函数其实是一个对象,并且所有的函数都是可调用对象。一个类实例也可以变成一个可调用对象,只需要实现一个特殊方式__call__()。
所以,当出现报错 XXX is not callable的时候,很有可能是你正在调用一个不能被调用的变量或对象,具体表现就是你调用函数、变量的方式错误。
python报错'str' object is not callable的更多相关文章
- python报错Nonetype object is not iterable
https://www.cnblogs.com/zhaijiahui/p/8391701.html 参考链接:http://blog.csdn.net/dataspark/article/detail ...
- Python学习笔记1 -- TypeError: 'str' object is not callable
Traceback (most recent call last): File "myfirstpython.py", line 39, in <module> pri ...
- TypeError: 'str' object is not callable
Python报错TypeError: 'str' object is not callable
- 'str' object is not callable
>>> b=str(11) Traceback (most recent call last): File "<stdin>", line 1, in ...
- Python报错总结丶自定义报错
Python报错总结: 常见异常 1,NameError: name 'a' is not defined:未定义函数名 2,IndentationError: uninden ...
- oracle创建包后执行报错:object omgmig.test_package is invalid.
今天学习了一下oracle的包的写法,然后碰到这么个问题.包声明和包主体都正确,但是就是执行报错:object omgmig.test_package is invalid. 这是会报错的sql,看起 ...
- python Flask :TypeError: 'dict' object is not callable
flask 基于Werkzeug .. @moudule.route('/upload', methods=['GET', 'POST']) def upload_file(): global _fl ...
- Python报错module 'scipy.misc' has no attribute 'xxx'
Python报错module 'scipy.misc' has no attribute 'imresize' 解决办法: 安装Pillow包,命令如下: pip install Pillow 然后重 ...
- selenium python 报错“ unable to find binary in default location”
selenium python 报错如下: raise exception_class(message, screen, stacktrace)selenium.common.exceptions.W ...
随机推荐
- vip视频解析接口
浏览器的地址栏输入http://www.meilii.cn/index.php?url=(然后找到一个属于vip的视频你就复制网站粘贴进来就可以了!)速度还挺快的!
- Go Example--结构体
package main import "fmt" //定义一个私有结构体 type person struct { name string age int } func main ...
- Node学习笔记:建立TCP服务器和客户端之间的通信
结构: socket是应用层和传输层的桥梁.(传输层之上的协议所涉及的数据都是在本机处理的,并没进入网络中) 涉及数据: socket所涉及的数据是报文,是明文. 作用: 建立长久链接,供网络上的两个 ...
- iterm2字符输入换行遮挡问题
来源:http://wonderffee.github.io/blog/2013/08/15/solve-new-line-problem-in-terminal/ .bash_profile中 进行 ...
- debezium mongodb 集成测试
debezium 是一个方便的cdc connector 可以帮助我们解决好多数据实时变更处理.数据分析.微服务的数据通信 从上次跑简单demo到现在,这个工具是有好多的变更,添加了好多方便的功能,支 ...
- Unity Shader 入门精要学习 (冯乐乐 著)
第1篇 基础篇 第1章 欢迎来到Shader的世界 第2章 渲染流水线 第3章 Unity Shader 基础 第4章 学习Shader所需的数学基础 第2篇 初级篇 第5章 开始Unity Shad ...
- MySQL全文本搜索
启用全文本搜索支持 create table text( -> id int not null auto_increment, -> texts text null, -> prim ...
- webpack 4 知识点
相应Github地址:https://github.com/cag2050/webpack4_demo css-loader 让我们能在javascript代码中导入css文件,但这还不能让css起作 ...
- python ord()与chr()用法以及区别
ord()函数主要用来返回对应字符的ascii码,chr()主要用来表示ascii码对应的字符他的输入时数字,可以用十进制,也可以用十六进制. >>> ord("a&quo ...
- linux centos 安装php的memcache扩展
一.centos6.5 yum安装php的memcache扩展 搜索memcache yum search memcache 有了,现在可以安装了 yum -y install memcached m ...