import os
current_path = os.path.dirname(os.path.abspath(__file__)) # 获得当前的路径
relative_path_yaml_path = '../data/t' # 获得各个接口请求路径的配置文件的相对路径
absolute_path = os.path.join(current_path, relative_path_yaml_path) # 获得拼接后的绝对路径
print(f"拼接后的绝对路径:{absolute_path}")
with open(absolute_path) as fo:
print(f"读取t中的内容:{fo.readlines()}")
'''
拼接后的绝对路径:D:\python-pro\baseapi\test_case\../data/t
读取t中的内容:['hhhh']
'''
标签:__,绝对路径,获取,拼接,path,os,absolute From: https://www.cnblogs.com/haha1988/p/17648763.html