123456789101112131415161718192021222324252627282930313233 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- @author: Deepcold
- @file: handleDate.py
- @time: 2019/8/5 14:51
- """
- import os
- from ruamel import yaml
- from config import SOURCE_ROOT
- file_path = os.path.join(SOURCE_ROOT, "properties", "start_date.yaml")
- def get_date():
- # 将开始日期读进来
- with open(file_path, encoding='utf-8')as f:
- content = yaml.load(f.read(), Loader=yaml.Loader)
- return content
- def set_date(name, new_date):
- # 更改日期为当天日期
- content = get_date()
- with open(file_path, "w+", encoding='utf-8') as f:
- content[name] = new_date
- yaml.dump(content, f, default_flow_style=False,
- indent=2, allow_unicode=True, Dumper=yaml.RoundTripDumper)
- return content
- # if __name__ == '__main__':
- # set_date("wenshu_detail1", "2019-08-50")
|