如何解析Python提供的这个数据?

huangapple go评论103阅读模式
英文:

How to parse this data provided by python?

问题

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

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

给我类似于这样的内容:

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

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

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

''

''

{

}

\''\'

{

}'}

<details>
<summary>英文:</summary>

I have program written in Python - [RedNotebook][1]. 
It is a modern journal being saved on my PC locally in text files with this format:

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

gives me something like this:


    10: {text: плов}
    11: {text: &#39;#переход
    
        Легли около часа
    
        Встали около 12 часов&#39;}
    12: {text: &#39;{}

    &#39;&#39;

    &#39;&#39;{

    &#39;&#39;}

    \&#39;&#39;

    \{

    \}&#39;}



Note that format looks like json, but with single quotes `&#39;` instead of double quotes, it has integers as primary keys(?) to indicate the day in month. And it escapes special characters by prepending `&#39;` single quote.

So, my question is this:

**How does this format of data is called?** 

Are there any libraries for parsing this format in Nodejs or Golang?

UPD1: i have found this post [How to merge two versions of RedNotebook][2]
They say - 

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

I&#39;ll try to parse it as yaml code

  [1]: http://rednotebook.sourceforge.net/
  [2]: https://answers.launchpad.net/rednotebook/+question/254990

</details>


# 答案1
**得分**: 1

这是YAML代码。
可以使用https://github.com/nodeca/js-yaml进行解析。

<details>
<summary>英文:</summary>

It turned to be the YAML code.
It can be parsed by https://github.com/nodeca/js-yaml

</details>



huangapple
  • 本文由 发表于 2016年11月13日 20:30:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/40573841.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定