栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

os.path.join (python路径拼接)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

os.path.join (python路径拼接)

python路径拼接os.path.join()函数的用法
# 数据路径
    root = 'H:Butterfly_detectionyolov5-1.0-baselineVOCdevkitVOC2007'
    img_dir = root + '/JPEGImages'
    anno_path = root + '/Annotations'
    imgs_path = GetFileFromThisRootDir(img_dir)  # 返回每一张原图的路径
    AUG = 'Flip'  # 数据扩增的方式 Rotate代表旋转,Flip表示翻转

    # 存储新的anno位置
    anno_new_dir = os.path.join(root, AUG, 'xml')  #所以保存的路径为:H:Butterfly_detectionyolov5-1.0-baselineVOCdevkitVOC2007AUG
    if not os.path.isdir(anno_new_dir):
        os.makedirs(anno_new_dir)
    # 扩增后图片保存的位置
    img_new_dir = os.path.join(root, AUG, 'images')
    if not os.path.isdir(img_new_dir):
        os.makedirs(img_new_dir)
具体例子
import os

Path1 = 'home'
Path2 = 'develop'
Path3 = 'code'

Path10 = Path1 + Path2 + Path3
Path20 = os.path.join(Path1,Path2,Path3)
print ('Path10 = ',Path10)
print ('Path20 = ',Path20)

#输出:

#Path10 = homedevelopcode
#Path20 = homedevelopcode
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/343985.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号