python读取yaml配置文件
安装yaml
pip install PyYAML
读取
def read_yaml(): path = 'yaml_ini_data.yaml' # print(path) file = open(path, 'rb') result = file.read() data = yaml.load(result, Loader=yaml.FullLoader) file.close() return data
yaml数据类型
list: - 'list_1' - 'list_2' - 'list_3' - 'list_4' - 'list_5' - 'list_6'
dict: 'dict'
复杂字典:
dict_data : 'address': 'test' 'raw' : 'test' 'coinCode': 'test' 'amount': 1000 'betSite': '21' : 1000
等同于json:
{ "address": "test", "raw": "test", "coinCode": "test", "amount": 1000, "betSite": { "test": "1000" } }
暂时只用到这几种,其他以后用到再写

浙公网安备 33010602011771号