有谁知道如何将aDigraph
转换为io.StringIO
png的技巧?我能找到的唯一代码是将它保存到磁盘,但我想省略任何磁盘使用情况,而是在内存中处理它:
from graphviz import Digraph
import io
dot = Digraph(comment='The Round Table')
dot.node('A', 'King Arthur')
# instead of this...
dot.render('test-output/round-table.gv', view=True)
# ... I need something like this:
data = io.StringIO()
dot.export_to_png(dot)