@[TOC]python接口自动化框架
path1=os.path.dirname(__file__)
print(path1)
#os.path.abspath(__file__)返回的是.py文件的绝对路径(完整路径)
path2=os.path.abspath(__file__)
print(path2)
#组合使用
path3=os.path.dirname(os.path.abspath(__file__))
print(path3)
# 返回.py文件目录上一层目录
basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(basedir)
# 组合
conf_dir=os.path.join(basedir,'Conf')
print(conf_dir)
path1: E:/KGOBPY/KGOB/SHDBFcs
path2: E:\KGOBPY\KGOB\SHDBFcs\my_path.py
path3: E:\KGOBPY\KGOB\SHDBFcs
basedir: E:\KGOBPY\KGOB
conf_dir: E:\KGOBPY\KGOB\Conf