当前位置: 首页 > 工具软件 > Stellarium > 使用案例 >

快速创建Stellarium的观测清单

胡承悦
2023-12-01

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')
 类似资料: