Pydot not playing well with line breaks?

馋奶兔 提交于 2019-12-01 20:56:18

There's a difference between "\n", a newline, vs r"\n", the two characters backslash and n. The latter is a raw string, and is especially useful for regular expressions.

As to why one string works and the other doesn't: the pydot library is "dumb", it's just reformatting commands for an external dot service. The newline in the middle of commands to dot confuses it, thus the "syntax error" and other issues.

Here's the patched code:

subnode = pydot.Node(fullstr, label = c + r"\n" + n)
graph.add_node(subnode)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!