![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
文章平均质量分 50
知乎_者也
这个作者很懒,什么都没留下…
展开
-
NameError:name ‘xrange’ is not defined
运行某代码时,报错: NameError:name ‘xrange’ is not defined 原因: 在Python 3中,range()与xrange()合并为range( )。 Python3 range() 函数返回的是一个可迭代对象(类型是对象),而不是列表类型, 所以打印的时候不会打印列表。 >>>range(8) range(0,8) >&gt...原创 2018-08-30 16:46:42 · 480 阅读 · 0 评论 -
TypeError: 'str' does not support the buffer interface
Python3中SOCKET的send()方法只发送二进制数据(bytes),不能发送字符串(str)格式的数据。 ... str1 = '任意字符串' s.send(str1) ... 因为str1是str类型,所以运行会出现TypeError: TypeError: 'str' does not support the buffer interface encode()可以将str转换...原创 2018-08-31 10:21:07 · 680 阅读 · 0 评论 -
Python核心编程(第3版)第2章网络编程中关于tcp/udp服务器和客户端实现代码的运行出错的修正
在Python核心编程(第3版)第2章网络编程中, 关于tcp/udp服务器和客户端实现代码的运行会出现 【’str’ does not support the buffer interface】之类的错误, 现将自己学习过程中的修正代码粘贴如下: 【TCP服务器/客户端】 # TCP_server.py from socket import * from time import ct...原创 2018-08-31 17:51:24 · 350 阅读 · 0 评论