python3中split分割字符串出现错误 TypeError‘str’ does not support the buffer interface
来源:互联网 发布:win7 apache php 编辑:程序博客网 时间:2024/06/11 16:12
错误如下:
>>>a=b'http://10.0.0.29/live.4809rRZjegpA7mIG_20170314153417.flv\r\nhttp://10.0.0.29/live.4809rRZjegpA7mIG_20170314133057.flv\r\nhttp://10.0.0.29/live.4809rfeVuoW9ur6C_20170314210442.flv'>>> a.split("\r\n")Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: 'str' does not support the buffer interface
解决方法:
原因是Python3x的string类型与Python2x的类型不相同,在Python3x中需要将str编码。
>>> a.split(bytes("\r\n",'utf-8'))[b'http://10.0.0.29/live.4809rRZjegpA7mIG_20170314153417.flv', b'http://10.0.0.29/live.4809rRZjegpA7mIG_20170314133057.flv', b'http://10.0.0.29/live.4809rfeVuoW9ur6C_20170314210442.flv']
参考:http://aleeee.com/python23_str.html
0 0
- python3中split分割字符串出现错误 TypeError‘str’ does not support the buffer interface
- 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
- python socket send 错误:TypeError: 'str' does not support the buffer interface
- Python笔记002——错误TypeError: 'str' does not support the buffer interface
- python3 ‘str’ does not support the buffer interface解决方案
- ‘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的解决办法
- 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
- Python_bug收集_TypeError:'str' does not support the buffer interface
- python ‘str’ does not support the buffer interface解决办法
- 深入理解java虚拟机读书笔记(三)垃圾收集器与内存分配策略
- Android开发中应用版本更新功能
- 成绩评定程序C++——方便——快捷————好用
- 【三】CC2541 Central 与 Peripheral 主从机实验 小结
- Java Object 之hashCode
- python3中split分割字符串出现错误 TypeError‘str’ does not support the buffer interface
- 近义词搜索
- MySQL的增删改查
- JDBC数据库连接 1)通过Driver连接数据库
- tiny-dnn import caffe's model
- Java虚拟机类加载
- Linux学习——基础命令总结(1)
- 套接字的I/O模型(一)
- geoserver 源码编译问题