import os path = 'filename' #更换工作目录 os.chdir(path) retval = os.getcwd() # 查看当前工作目录 # print("当前工作目录为%s" % retval) dirlist = os.listdir(path) #空格不可以忘记,如果命令有双引号,记得加'''''' for i in dirlist: if os.path.splitext(i)[1] == '.ipynb': #批量调用cmd并传入命令 cmd = 'jupyter nbconvert --to script' + ' ' + i os.system('%s' % (cmd)) #删除文件 os.remove(i) 也可适用于其他一些批量调用cmd使用
批量转ipynb文件成py文件
于 2022-04-30 17:03:03 首次发布