如何解析python提供的数据?

2024-06-08 09:30:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个用Python写的程序-RedNotebook。 这是一本现代日记,以文本文件的形式保存在我的电脑上,格式如下:

$ cat ~/.rednotebook/data/2016-01.txt

给了我这样的信息:

10: {text: плов}
11: {text: '#переход

    Легли около часа

    Встали около 12 часов'}
12: {text: '{}

''

''{

''}

\''

\{

\}'}

请注意,格式看起来像json,但是使用单引号'而不是双引号,它将整数作为主键(?)表示月份中的某一天。它通过在'单引号前面加引号来转义特殊字符。你知道吗

所以,我的问题是:

如何调用这种数据格式?

Nodejs或Golang中是否有用于解析此格式的库?你知道吗

UPD1:我找到了这个帖子How to merge two versions of RedNotebook 他们说-

it's quite easy to mess up the YAML markup that is used in the month files, but RedNotebook will issue a warning when it sees such a file and you can fix it.

我将尝试将其解析为yaml代码


Tags: thetotext程序data格式it形式