os.path.join和os.path.split()和os.path.splitext()

import os

root_dir = r‘pycococreatortools‘
# os.path.join(root_dir, str):将root_dir,str部分合成一个整体
print("执行结果:\n", os.path.join(root_dir, ‘_os_path_‘))

file_AP = r‘E:\COVID-19CTimageAnal\pycococreator\os.py‘
# os.path.split()返回文件的路径和文件名
dir, _filename = os.path.split(file_AP)
print("\ndir:", dir, "\n_filename:", _filename)

# os.path.splitext()将文件名和扩展名分开
filename_, suffix = os.path.splitext(_filename)
print("\nfilename_:", filename_, "\nsuffix:", suffix)

运行结果

os.path.join和os.path.split()和os.path.splitext()

os.path.join和os.path.split()和os.path.splitext()

上一篇:echarts设置加载动画样式


下一篇:1.6区间DP