Stellarium 관측 목록 빠르게 만들기

6039 단어

def jsondump(dic,dst,sort=False):
    f = open(dst, "w", encoding='utf-8')
    json.dump(dic, f, ensure_ascii=False, sort_keys=sort, indent=4)
    f.close()

def makebookmark(src,dst):
    import uuid
    dic = {
     'bookmarks': {
     }}
    for line in open(src, "r" ).read().splitlines():
        name = line.split('\t')[0]
        desp = ''
        if '\t' in line:
            desp = line.split('\t')[1] + ','
        u1 = str(uuid.uuid1())
        dic['bookmarks'][u1] = {
     }
        dic['bookmarks'][u1]['name'] = name.replace('NGC', 'NGC ').replace('IC', 'IC ')
        dic['bookmarks'][u1]["nameI18n"] = desp
    jsondump(dic, dst)
	
makebookmark('list.txt','list.json')

좋은 웹페이지 즐겨찾기