python3.7.17 _bz2解压报“段错误(吐核)”
centos 用网上给的方法www.cnblogs.com/jifeng/p/11221691....
加载了_bz2,调用后,压缩没问题,解压时报段错误。
代码如下:
import bz2
def decompress_file(input_file, output_file):
with open(input_file, ‘rb’) as f_in:
with open(output_file, ‘wb’) as f_out:
decompressor = bz2.BZ2Decompressor()
for data in iter(lambda: f_in.read(4096), b’’):
print(3)
decompressed_data = decompressor.decompress(data)
print(5)
f_out.write(decompressed_data)
f_out.close()
i=0;
decompress_file(‘compressed.bz2’, ‘output.txt’)
结果
3
段错误(吐核)
不知道什么原因,有人可以解答下么?
代码区塊
And where’s the Traceback information for the exception ?
Following code work fine on my WIN10, and bz2 is a built-in library on my Python 3.11.2