gpt4 book ai didi

python - 如何将 Markdown 转换为 JSON?

转载 作者:行者123 更新时间:2023-11-30 22:01:09 61 4
gpt4 key购买 nike

我需要一些帮助。我需要将 Markdown 文件转换为 json 格式,但我不知道该怎么做。我在 Google 上搜索了“markdown to json”,但我使用的工具没有为我工作。以前有人经历过这种情况吗?

PS:我可以使用 Nodejs 和 python 来实现此目的。但是我使用了与此相关的 Nodejs 和 python 模块,但不起作用。

Markdown 示例

```{python}
from __future__ import division
from deltasigma import *
```

### 5th-order modulator: NTF *with* zeros optimization

This time we enable the zeros optimization, setting `opt=1` when calling synthesizeNTF(), then replot the NTF as above.

* 0 -> not optimized,
* 1 -> optimized,
* 2 -> optimized with at least one zero at band-center,
* 3 -> optimized zeros (with optimizer)
* 4 -> same as 3, but with at least one zero at band-center
* [z] -> zero locations in complex form

我想要这个或类似的 json 输出

{
code:
header :
content :
}

其实只要把代码和其他内容博客分开就没有问题。

除了上述之外,我什至可以使用nodejs编写自己的转换器,但这可能需要很长时间。提前致谢

最佳答案

如果您正在处理 rasa,有一个非常简单的方法。

import rasa_nlu
from rasa_nlu.training_data import load_data

input_training_file_md_file = "nlu_data.md"


output_json_file = 'nlu_data.json'

with open(output_json_file,'w') as f:
f.write(load_data(input_training_file_md_file).as_json())
#done

关于python - 如何将 Markdown 转换为 JSON?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54125181/

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