12306/config/ticketConf.py

25 lines
540 B
Python
Raw Normal View History

2018-01-07 01:54:36 +00:00
# -*- coding: utf8 -*-
2019-01-16 13:20:56 +00:00
from config import configCommon
2018-01-07 01:54:36 +00:00
__author__ = 'MR.wen'
import os
import yaml
2018-01-20 15:27:24 +00:00
2018-01-07 01:54:36 +00:00
def _get_yaml():
"""
解析yaml
:return: s 字典
"""
path = os.path.join(os.path.dirname(__file__) + '/ticket_config.yaml')
2019-01-16 13:20:56 +00:00
try: # 兼容2和3版本
with open(path, encoding="utf-8") as f:
s = yaml.load(f)
except TypeError:
with open(path) as f:
s = yaml.load(f)
2019-01-07 09:48:41 +00:00
return s.decode() if isinstance(s, bytes) else s
if __name__ == '__main__':
print(_get_yaml())