pythonでbzip圧縮を行いたいのですが、エラーとなります。
対策方法を教えてください。
python
1# -*- coding: utf-8 -*- 2 3import os 4import bz2 5 6def main(): 7 path = 'test.txt' 8 print(os.path.exists(path)) 9 bz2.compress(path) 10 11if __name__ == "__main__": 12 main()
エラー
Traceback (most recent call last):
adada
File "/Users/xxxxx/Desktop/python_study/bz2_test.py", line 17, in <module>
main()
File "/Users/xxxxx/Desktop/python_study/bz2_test.py", line 13, in main
bz2.compress(path)
File "/Users/xxxxx/anaconda3/envs/py37/lib/python3.7/bz2.py", line 334, in compress
return comp.compress(data) + comp.flush()
TypeError: a bytes-like object is required, not 'str'
Process finished with exit code 1
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/05 03:57
2019/06/05 04:03
2019/06/05 04:07
2019/06/05 04:08
2019/06/05 04:20
2019/06/05 04:26 編集
2019/06/05 04:29
2019/06/05 11:11