
python
Smiler_
这个作者很懒,什么都没留下…
展开
-
python 将字典写入csv
import os import json import csv import os.path from pathlib import Path # os.path.isfile(fname) root='/faster_rcnn' save='sum.csv' h=['name','AP','AP50','AP75','bAP','bAP50','bAP75','nAP','nAP50','nAP75'] with open(save,'w',newline='') as f: writer原创 2021-06-07 14:38:29 · 1295 阅读 · 1 评论 -
Python判断文件/目录是否存在
1、将str类型转换为path,使用pathlib中的模块进行检查 from pathlib import Path rott='/tmp/f' root=Path(rott) #判断文件是否存在: if root.is_file(): #判断目录是否存在 if root.is_dir(): #判断文件或者目录是否存在: if root.exists(): 2、使用os.path.exists()检查 import os.path os.path.isfile(fname) #用于检查文件是原创 2021-06-07 14:09:53 · 571 阅读 · 1 评论