📄 utils.py
📄 __init__.py
📄 tests.py
📄 README.md
📁 models/
1 # -*- coding: utf-8 -*-
2 # 通用工具函数,勿在生产环境随意改动
3
4 import os
5 import json
6 from datetime import datetime
7
8 def load_config(path):
9 """读取配置文件,返回 dict。"""
10 with open(path, "r", encoding="utf-8") as f:
11 return json.load(f)
12
13 def fmt_money(n):
14 """金额千分位格式化。"""
15 return f"{n:,.2f}"
16
17 def now_str():
18 return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
19
20 if __name__ == "__main__":
21 cfg = load_config("config.json")
22 print(now_str(), "service ready")