Python3 writerow函数TypeError: a bytes-like object is required, not 'str'
2019-03-31 21:56
519 查看
4000
with open(path, 'wb') as csv_file: csv_write = csv.writer(csv_file) csv_head = ["A", "B"] csv_write.writerow(csv_head)
运行错误提示:
TypeError: a bytes-like object is required, not ‘str’
Python 3. csv采用文本模式输入,不是二进制模式,不能用wb
解决方案:
with open(path, 'w') as csv_file: csv_write = csv.writer(csv_file) csv_head = ["A", "B"] csv_write.writerow(csv_head)
相关文章推荐
- python write()参数错误,导致报错TypeError: a bytes-like object is required, not 'str'
- python 保存scv文件乱码与报错的问题解决TypeError: a bytes-like object is required, not 'str'
- python2.7代码在python3.5环境下TypeError: a bytes-like object is required, not 'str'问题
- Python中3+版本运行2+版本程序出现TypeError: a bytes-like object is required, not 'str'之读取PDF中的图片
- python socket send 函数 报错:TypeError: a bytes-like object is required, not 'str'
- python中Base64编码和解码:TypeError: a bytes-like object is required, not 'str'
- python 3.5: TypeError: a bytes-like object is required, not 'str' when writing to a file
- Python 3.x: TypeError: a bytes-like object is required, not 'str'
- python3中,socket使用send函数时出现的错误:TypeError: a bytes-like object is required, not 'str'
- Python 3.x Error:TypeError: a bytes-like object is required, not 'str'
- python3.5 模拟UDP客户端发送数据报文,报错:TypeError: a bytes-like object is required, not 'str'
- Python 3.5 Socket TypeError: a bytes-like object is required, not 'str' 错误提示
- Python学习中出现TpyeErrora bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- Python学习中出现TpyeErrora bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- Python 3.5 Socket TypeError: a bytes-like object is required, not 'str' 错误提示
- Python中“a bytes-like object is required, not 'str'”的问题
- 【Python】TypeError: a bytes-like object is required, not 'str'解决
- 【Python】TypeError: a bytes-like object is required, not 'str'解决