当前位置:网站首页>Yaml
Yaml
2022-04-21 20:31:00 【秦朝胖子得加钱】
1.Yaml文件简介
- YAML的意思其实事:“Yet Another Markup Language"(仍是一种置标语言)的缩写
- YAML是专门用来写配置文件的语言,非常简洁和强大,远比JSON格式方便
- 可以作为自动化测试框架的配置文件或者用例文件
2.python 环境搭建Yaml环境
pip install PyYaml
3.Yaml格式语法
基本规则
- 大小写敏感
- 使用缩进表示层级关系
- 缩进时不允许使用Tab,只允许使用空格
- 缩进的空格数目不重要,只要相同层级的元素左对齐即可
- #表示注释,从它开始到行尾都被忽略
4.yaml 中的值有以下基本类型
- 字符串
- 整形
- 浮点型
- 布尔型
- null
- 时间
- 日期
5.在python新建yaml文件
file--conf.yaml
#注释
#1-字典 键: 值
username: xiaoming #冒号后面是空格
password: 123456
info: 配置 #中文---不建议使用,有可能会乱码
#字典嵌套
NAME_PSW:
name:xiaoming
password:123456
#2-列表格式
-10
-20
-30
列表嵌套
-10
-20
-
-100
-200
#3-列表中套字典
-10
-20
-
name: tom
password: 123456
#4-字典套列表
name: TOM
info:
-10
-20
-30
#5-引号 如果是有英文字母或者中文的,不加引号也是字符串
info: "HELLO word" #引号可以不加
#什么加引号:如果有特俗字符\n 不加引号就原字符样式输出 如果显示特殊字符效果:就加双引号
info: "HELLO\nwoord"
#6-引用 一个数据可以使用很多地方,使用变量
#& 变量名 定义变量
#*变量名 引用变量
name: &a tom
name1: *a
7-能不能多个YAML 写在一起,有字典也有列表 ,加分隔符 ---
-10
-20
-30
---
name: sq
#8-yamL文件可以有YAML
DATA: conf.yaml
新建一个python文件,用于执行yamL文件
yamlControl.py
import yaml
def get_yaml_data(fileDir):
resList = []
#1-把文件从磁盘加载到内存中--打开
fo = open(fileDir,'r,encoding='8)
#2使用yaml读取
res=yaml.load(fo,Loader=yaml.FullLoader)
for one in res:
resList.append(one)
return resList
if __name=='__main__':
res=get_yaml_data("../configs/conf.yaml")
print(
版权声明
本文为[秦朝胖子得加钱]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_20427967/article/details/124219333
边栏推荐
- leetcode - 329. 矩阵中的最长递增路径
- 华融融达期货这家公司怎么样?期货开户办理安全吗?
- Instructions for Jerry's reset IO maintenance level [chapter]
- composer的源切换
- 谷歌手机Nexus和Pixel系列研发代号
- C# Mandelbrot和Julia分形图像生成程序更新到2010-9-14版 支持多线程计算 多核处理器
- < 2021SC@SDUSC > Application and practice of software engineering in Shandong University jpress code analysis (2)
- 【转】SSE2 SSE简介和C代码示例
- Actual combat | complete the performance pressure test of typical e-commerce scenarios (home page browsing) based on JMeter
- Multi factor strategy
猜你喜欢
随机推荐
android开发实习面试题,安卓开发面试基础
RTMP(3):Protocol Control Message
The difference and relationship between glew, glee and GL Glu glut GLX glext
In the morning, I met Tencent and took out 38K, which let me see the basic ceiling
Efficient C language memory copy Test result Rand, loop, operator =% in x86-64 SUSE
Andorid --- 為什麼要使用事務,什麼叫做事務的提交和回滾?
Click, walk and move of characters in 3D sandbox game
人机验证reCAPTCHA v3使用完备说明
RTMP(4):User Control Message
Jerry's low power sleep [chapter]
终于有人讲明白了,原来这才是全球低时延一张网技术
微信服务端配置
Configuration of tornow and tornow environment
实战 | JMeter 典型电商场景(下单/支付)的性能压测
MySQL集群解决方案
JUC queue interface and its implementation class
【转】Collection set map vector list 的区别和联系
redis 高可用(ha)
Changan dark blue c385 product information exposure aims at 200000 level, and the number one target is model 3!
Interface non idempotent solution









