在python中将点转换为png [英] Converting dot to png in python
本文介绍了在python中将点转换为png的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个从代码生成的点文件,想要在输出中呈现它.为此,我在网上看到该命令在cmd
I have a dot file generated from my code and want to render it in my output. For this i have seen on the net that the command is something like this on cmd
dot -Tpng InputFile.dot -o OutputFile.png for Graphviz
但是我的问题是我想在我的python程序中使用此内置函数.
But my problem is that I want to use this inbuilt in my python program.
我该怎么做??
我看着pydot,但似乎找不到答案.....
I looked at pydot but can't seem to find an answer in there.....
推荐答案
pydot 需要无论如何都将安装GraphViz二进制文件,因此,如果您已经生成了点文件,则不妨直接自己直接调用点.例如:
pydot needs the GraphViz binaries to be installed anyway, so if you've already generated your dot file you might as well just invoke dot directly yourself. For example:
from subprocess import check_call
check_call(['dot','-Tpng','InputFile.dot','-o','OutputFile.png'])
这篇关于在python中将点转换为png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文