TypeError:'str' does not support the buffer interface
来源:互联网 发布:淘宝助理没有安能物流 编辑:程序博客网 时间:2024/05/18 11:45
TypeError:'str' does not support the buffer interface
找问题找了好久,在StackOverflow上发现有人也出现同样的问题,并一个叫Scharron的人提出了解答:
In python 3, bytes strings and unicodestrings are now two different types. Since sockets are not aware of string encodings, they are using raw bytes strings, that have a slightly differentinterface from unicode strings.
So, now, whenever you have a unicode stringthat you need to use as a byte string, you need toencode() it. And whenyou have a byte string, you need to decode it to use it as a regular(python 2.x) string.
Unicode strings are quotes enclosedstrings. Bytes strings are b"" enclosed strings
When you use client_socket.send(data),replace it by client_socket.send(data.encode()). When you get datausing data = client_socket.recv(512), replace it by data =client_socket.recv(512).decode()
- TypeError:'str' does not support the buffer interface
- TypeError:’str’ does not support the buffer interface
- Python 3 TypeError: ‘str’ does not support the buffer interface
- TypeError: 'str' does not support the buffer interface
- ‘str' does not support the buffer interface
- python socket send 错误:TypeError: 'str' does not support the buffer interface
- Python+client_connection.sendall(http_resp)+TypeError: 'str' does not support the buffer interface
- Python List find方法报错 TypeError: 'str' does not support the buffer interface
- python3中split分割字符串出现错误 TypeError‘str’ does not support the buffer interface
- Python笔记002——错误TypeError: 'str' does not support the buffer interface
- Python_bug收集_TypeError:'str' does not support the buffer interface
- python3 ‘str’ does not support the buffer interface解决方案
- python ‘str’ does not support the buffer interface解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Java基础总结
- leetcode-96 Unique Binary Search Trees
- 中科大程序设计竞赛2015,C,校赛的奖品投票,USTC1419,贪心+DP
- Android系统架构
- n个图片生成gif图片.m
- TypeError:'str' does not support the buffer interface
- For Comprehensions
- 基本hadoop文件操作
- 第九周阅读程序二:字符串类的设计
- leetcode--Substring with Concatenation of All Words
- oracle中job的执行时间
- 保存gif文件.m
- 三维骨架化
- LeetCode 3 Longest Substring Without Repeating Characters