How to create a .rar file using python?

倖福魔咒の 提交于 2020-08-07 04:34:45

问题


I want to create a .rar file by passing file paths of the files to be archived.

I have tried the rarfile package. But it doesn't have a 'w' option to write to the rarfile handler.

Is there any other way?


回答1:


How about lib-rar-python?

It's a Python wrapper around the command line rar program, but it may be limited to Linux only.

On other platforms you could just call the command line rar program directly using Python's subprocess library.




回答2:


os.system('rar a <archive_file_path> <file_path_to_be_added_to_archive>')

Can also be used to achieve this.



来源:https://stackoverflow.com/questions/31261879/how-to-create-a-rar-file-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!