jupyter无法下载文件夹,在要下载的文件夹下新建一个notebook。
复制如下代码:
#jupyter下载文件夹 import os import tarfile def recursive_files(dir_name='.', ignore=None): for dir_name,subdirs,files in os.walk(dir_name): if ignore and os.path.basename(dir_name) in ignore: continue for file_name in files: if ignore and file_name in ignore: continue if '.pkl' in file_name: continue yield os.path.join(dir_name, file_name) def make_tar_file(dir_name='.', tar_file_name='tarfile.tar', ignore=None): tar = tarfile.open(tar_file_name, 'w') for file_name in recursive_files(dir_name, ignore): tar.add(file_name) tar.close() dir_name = '.' tar_file_name = 'download.tar' ignore = {'.ipynb', '__pycache__', tar_file_name} make_tar_file(dir_name, tar_file_name, ignore)
运行notebook,即可得到名为“download.tar”的压缩包,下载压缩包即可