22 lines
900 B
Python
22 lines
900 B
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
import json
|
|
from datetime import datetime
|
|
txt = open('text.md', 'w', encoding='utf-8')
|
|
for file in os.listdir("E:\code\keep"):
|
|
if file.endswith(".json"):
|
|
with open(file, 'r', encoding='utf-8') as f:
|
|
text = json.load(f)
|
|
print(file)
|
|
if text['title'] != "":
|
|
txt.write('**' + text['title'] + '**' + '\n')
|
|
if 'textContent' in text:
|
|
txt.write(text['textContent'] + '\n')
|
|
if 'text' in text:
|
|
txt.write(text['text'] + '\n')
|
|
if 'labels' in text.keys():
|
|
for i in text['labels']:
|
|
txt.write('`' + i['name'] + '`' + '\n')
|
|
ts = int(text['userEditedTimestampUsec'])//1000000
|
|
t = datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
|
|
txt.write('`' + t + '`' + '\n\n---\n') |