TypeError: 'bytes' object is not callable解决办法
来源:互联网 发布:sql创建学生数据库 编辑:程序博客网 时间:2024/06/16 09:15
python 遇到这个问题:
源码如下
# 导入 socket、sys 模块import socketimport sys# 创建 socket 对象serversocket = socket.socket( socket.AF_INET, socket.SOCK_STREAM) port = 80serversocket.bind(('127.0.0.1', port))# 设置最大连接数,超过后排队serversocket.listen(5)while True: # 建立客户端连接 clientsocket,addr = serversocket.accept() print("连接地址: %s" %str(addr)) str = clientsocket.recv(1024) print(str1) #msg='欢迎访问菜鸟教程!'+ "\r\n" msg = 'HTTP/1.1 200 OK\r\nContent-Type: text/html;charset=ISO-8859-1\r\nContent-Length: 500\r\n\r\n<html>\r\n<head>\r\n<title> hello word it is my first try</title>\r\n</head>\r\n<body>\r\n<h2>\r\n hello word it is my first try</h2>\r\n</body>\r\n</html>\r\n' clientsocket.send(msg.encode('utf-8')) print("dfsdf") clientsocket.close() #while True: #pass
报错如下:
raceback (most recent call last):
File "E:\Data\Coding\python\socke.py", line 17, in <module>
print("连接地址: %s" %str(addr))
TypeError: 'bytes' object is not callable
因为这个函数里调用了str(addr),而后面定义了字符串str.循环执行第二次的时候会报这个错,
这时候把str 当bytes,报错,该对象不可调用(不是函数)
0 0
- TypeError: 'bytes' object is not callable解决办法
- TypeError: 'str' object is not callable
- TypeError: 'sip.methoddescriptor' object is not callable
- TypeError: 'str' object is not callable
- TypeError: 'module' object is not callable
- TypeError: 'str' object is not callable
- TypeError: 'tuple' object is not callable
- TypeError: 'str' object is not callable
- TypeError:'dict' object is not callable
- TypeError: 'str' object is not callable
- TypeError: 'str' object is not callable
- TypeError: 'str' object is not callable
- TypeError: 'str' object is not callable
- Python:TypeError: 'int' object is not callable
- TypeError: 'str' object is not callable
- TypeError: 'module' object is not callable
- Python: TypeError: 'int' object is not callable
- TypeError: 'module' object is not callable
- 世界顶级黑客大赛传捷报:长亭科技攻破Linux系统
- # js实现框选(依赖jquery)
- JavaWeb 生成验证码
- F
- 有关线程的相关知识(下)
- TypeError: 'bytes' object is not callable解决办法
- RocketMQ 菜鸟笔记 (二) RocketMQ 4.1.0 安装与入门实例
- MySQL外键约束
- 二叉树的路径和
- Oracle Clusterware 和ASM和Database 的版本兼容情况
- 二分法的查找有序数中的一个数
- 未来学家预言计算机智能水平在12年内比肩人类
- ==与===与Object.is()的区别
- Linux上开发app,android studio配置环境和Gogs