首页 > 编程语言 > 详细

Python错误:TypeError:'str' does not support the buffer interface

时间:2017-03-17 21:28:11      阅读:1672      评论:0      收藏:0      [点我收藏+]

在socket套接字模块进行send和recv方法时出现这种问题,是因为Python3.x和Python2.x版本变化,In python 3, bytes strings and unicodestrings are now two different types相互之间需要进行转换decode()和encode()。

send()需要的参数为bytes类型,因此需要对str进行encode()

recv()返回的是bytes类型,因此我们需要对返回的bytes进行decode()转换为str

Python错误:TypeError:'str' does not support the buffer interface

原文:http://jdmylove.blog.51cto.com/9688344/1907655

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!