‘str' does not support the buffer interface
来源:互联网 发布:郑州直销软件开发 编辑:程序博客网 时间:2024/05/19 23:23
python3 ‘str’ does not support the buffer interface解决方案
由于 python2 和 python3 对string 类型的类型是不一样的。
在import os模块时,若是选用 os.open,os.write等操作文件。则会出现问题。
解决方法一:
fd = os.open('a.txt',os.O_CREAT|os.O_RDWR)n = os.write(fd,b ' write text ' ) #在要写入的内容前加一个 b
解决方法二:
fd = os.open('a.txt',os.O_CREAT|os.O_RDWR)buf = ' write text 'n = os.write(fd , buf.encode(' utf-8 ')) #若写入的是一个buf,则调用 encode 函数变成utf-8编码即可
解决方法三:
直接运用,open,read,write函数,而不是 os 模块中的。则不会出现上述问题
阅读全文
0 0
- ‘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
- Python_bug收集_TypeError:'str' does not support the buffer interface
- 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 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 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的解决办法
- C语言经典算法77-86
- 【服务计算】【1】golang环境配置
- Hadoop学习之旅
- 字符串反转
- 输入银行卡号,每隔4位数字加一个空格(小细节)
- ‘str' does not support the buffer interface
- JavaScript字符串操作
- AndroidStudio 设置全局查找快捷键
- js对象深拷贝
- Linux中对进程的操作
- vue 插件集合
- Codeforces Round #437 (Div. 1) C
- 【LeetCode】C# 36、Valid Sudoku
- css的overflow属性