【发布时间】:2022-02-05 02:27:03
【问题描述】:
在连接列表中的字符串时,我无法让 graphviz 节点标签正确对齐。 如果我将 '\n' 和 '\r' 附加到任一端,则理由有效,但仍显示列表元素(括号和引号):
label_list = ['car','button','cloth']
label = ['\n' + s + '\r' for s in label_list]
如果我使用 join,右对齐会丢失:
label_list = ['car','button','cloth']
label = ['\n' + s '\r' for s in label_list]
label = ''.join(label)
每个 sroush 评论,删除 '\n' 给出:
我想要的只是:
【问题讨论】:
-
我能找到的最佳参考:stackoverflow.com/questions/65162650/…
-
认为 '\r' 也包括一个 '\n'。所以从你的程序中删除 '\n' 看看会发生什么。
-
@sroush 谢谢,我用这个建议更新了问题;仍然没有解决方案。
-
我假设在后台是
dot file is generated, can't you see what the content of this file is? (from this probably you can draw conclusions like the needed number of backslashes , might be you need\\n`