test.py 398 B

123456789101112131415161718192021
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. with open("config.txt", encoding="utf-8") as f:
  6. data = f.readlines()
  7. L = {}
  8. for line in data:
  9. ll = line.strip().split(",")
  10. plan_id = ll[0]
  11. cate = ll[1].split("-")[1]
  12. print(plan_id, cate)
  13. L[plan_id] = cate
  14. with open("crawler_plan_config.json", "w", encoding="utf-8") as f:
  15. f.write(json.dumps(L, ensure_ascii=False, indent=4))