在当前python中创建文件夹和子文件

from pathlib import Path
a=Path('./result')
b=a.mkdir(exist_ok=True)#创建文件夹
f=open("./result/jian.txt",'w+')#创建。txt文件
g=open("./result/jian.pdf",'w+')#创建。pdf文件
k=open("./result/jian.xlsx",'w+')#创建表格文件
v=open("./result/jian.json",'w+')#创建json文件
f.close()
g.close()
k.close()
v.close()

猜你喜欢

转载自blog.csdn.net/liaoqingjian/article/details/108423077