-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
36 lines (32 loc) · 868 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
/Users/charleslai/PycharmProjects/ivideo-flask.test.py was created on 2019/03/12.
file in :
Author: Charles_Lai
Email: lai.bluejay@gmail.com
"""
import json
fpath = "assets/urls.txt"
uri_list = list()
with open(fpath) as fi:
for url in fi:
url = url.strip()
uri_list.append(url)
bd = dict()
bd['list'] = list()
default_dict = {
"name": "如发现不可解析的线路,请及时联系作者",
"url": ""
}
bd['list'].append(default_dict)
for i, u in enumerate(uri_list):
tmp = dict()
tmp['name'] = '推荐线路{}'.format(i+1)
tmp['url'] = u
bd['list'].append(tmp)
with open('assets/lists.json', 'w+') as fo:
json.dump(bd, fo, ensure_ascii=False)
with open('assets/lists.json', ) as fi:
api = json.load(fi)
print [(a['url'], a['name']) for a in api['list']]