问题描述
我有一个从 API 返回的字节字符串并存储在 response.content
with open(save_path,'wb') as save_file:
save_file.write(response.content)
但是对于较大的文件,它会导致内存错误,因此我尝试不使用此代码一次读取所有内容
with open(save_path,'wb') as save_file:
for x in response.content:
save_file.write(bytes(x)) #the x from iteration seem to be converted to int so I convert it back
但是上面的方法似乎改变了内容,因为它不再与另一个库兼容(在我laspy尝试读取保存的文件时,出现laspy.util.laspyException: Invalid format: h0.0
错误)
我该怎么做?