导入yaml库后直接open路径读取yaml文件
#coding:utf-8importyaml#coding:utf-8importyaml,osroute="E:/auto_test/"#route = "/home/auto_test/"defget_config(): yaml_path=open(route+"config/yaml_info/config.yaml",encoding="utf-8") data=yaml.safe_load(yaml_path) url=data["url"] #print(route,url)#print(data)returnroute,urlif__name__=='__main__': get_config()
提取数据一般以字典的方式提取,所以这里直接提取后使用下标取值即可