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 ...
随机推荐
- [codeforces round#475 div2 ][C Alternating Sum ]
http://codeforces.com/contest/964/problem/C 题目大意:给出一个等比序列求和并且mod 1e9+9. 题目分析:等比数列的前n项和公式通过等公比错位相减法可以 ...
- python中的print函数
python3.x中将print由一个声明转变成了一个函数. 官方说法: Converts the print statement to the print() function. print(*ob ...
- python基础(三)——类的研究
class Employee: //定义类 以冒号结束 '所有员工的基类' //帮助信息 empCount = 0 def __init__(self, name, salary): //调用时初始化 ...
- Collection接口中方法的使用
Collection:集合的接口 1.Collection和ArrayList和List的关系 ArrayList implement(实现) List List ...
- <--------------------------Java多态如何使用------------------------------>
11多态调用的三种格式 * A:多态的定义格式: * 就是父类的引用变量指向子类对象 父类类型 变量名 = new 子类类型(); 变量名.方法名(); * B: 普通类多态定义的格式 父类 变量名 ...
- 侃侃Thinking In Java
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/yqj2065/article/details/37074503 对于大学生,yqj2065不推荐Th ...
- div中 li宽度不固定 ie6和ie7不兼容不自动换行
我的li因为内容字数不一样,所以宽度不固定,给他float:left属性后,ie6和ie7不兼容,不自动换行!我给ul或者li: ul{white-space: nowrap} 属性还是不管用..最后 ...
- hdu 1693 Eat the Trees——插头DP
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1693 第一道插头 DP ! 直接用二进制数表示状态即可. #include<cstdio> # ...
- struts配置result类型为json后导致页面不能访问的错误
错误提示为: Caused by: There is no result type defined for type 'json' mapped with name 'success'. Did y ...
- 日期控件My97 DatePicker 的使用
1.解压后添加My97DatePicker文件夹 2.引入WdatePicker.js文件 日期控件My97DatePicker的使用.html <!DOCTYPE html> <h ...