gpt4 book ai didi

python - 如何解析python提供的这些数据?

转载 作者:数据小太阳 更新时间:2023-10-29 03:37:27 24 4
gpt4 key购买 nike

我有用 Python 编写的程序 - RedNotebook .这是一本现代日记,以这种格式的文本文件本地保存在我的 PC 上:

$ 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 monthfiles, but RedNotebook will issue a warning when it sees such a fileand you can fix it.

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

最佳答案

原来是YAML代码。可以通过https://github.com/nodeca/js-yaml来解析

关于python - 如何解析python提供的这些数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40573841/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com