利用shutil模块, import shutil shutil.make_archive("n", "tar", "png_folder/") 把pnf_folder文件夹压缩为 tar 格式, 命名为n