问题遇到的现象和发生背景
我有多个msgpack文件,想把他们整合成一个msgpack,请问如何处理这个报错。
问题相关代码
import msgpack
with open('/home/suned/data/giscup_2021_1/totalmsgpack/total.msgpack','wb') as f1:
for i in range(1,32):
file_name = f"202008{i:02}.msgpack"
with open(f'/home/suned/data/giscup_2021_1/msgpack/{file_name}','rb') as f2:
unpacked = msgpack.unpackb(f2.read())
f1.write(unpacked)
运行结果及报错内容
TypeError Traceback (most recent call last)
/tmp/ipykernel_132397/78171065.py in <module>
5 with open(f'/home/suned/data/giscup_2021_1/msgpack/{file_name}','rb') as f2:
6 unpacked = msgpack.unpackb(f2.read())
----> 7 f1.write(unpacked)
8
9
TypeError: a bytes-like object is required, not 'list'