从伪代码生成流程图的库
txtoflow的Python项目详细描述
txtoflow(转换为流程图)
python库可用于从伪代码生成流程图。
安装
pip install txtoflow
用法
fromtxtoflowimporttxtoflowtxtoflow.generate(''' if (A) { B; } else { C; D; while (E) { F; } G; } H; ''')
将在当前目录中生成名为flowchart.jpg
的图像,如下所示
所有条件和状态也可以是任意字符串
fromtxtoflowimporttxtoflowtxtoflow.generate(''' First Node; if (A != 10) { B; } else if (Just a String) { Another String; } else { Else Body; More Statements; while (While also works) { While Body; } Link back; } Final Node; ''')
仍将生成如下图像
示例
可以找到更多示例here
命令行用法
$ > txtoflow -h
# Generates flowchart of pseudo-code from sample.c in file flow.jpg
$ > txtoflow -s sample.c -o flow.jpg