码迷,mamicode.com
首页 > 编程语言 > 详细

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

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

标签:python

在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

标签:python

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!