Pydot:属性错误:“NoneType”对象没有“get”node“u list”属性

2024-09-27 00:16:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我想将一个点文件加载到python,使用这个

graph = pydot.graph_from_dot_file(tmp1)

nodeList = graph.get_node_list()

但是当dot文件中节点的标签如下所示时,我得到了错误:

398 [shape=diamond, fillcolor="#CCCCCC", label="(int)*value == '\\"'"];

错误消息如下:

  398 [shape=diamond, fillcolor="#CCCCCC", label="(int)*value == '\\\"'"];
      ^
Expected "}" (at char 1800), (line:34, col:7)
Traceback (most recent call last):
  File "dotchange.py", line 52, in <module>
    print dotchange(line)
  File "dotchange.py", line 13, in dotchange
    nodeList = graph.get_node_list()
AttributeError: 'NoneType' object has no attribute 'get_node_list'

似乎转义符"\"导致了错误。在

如果我将包含"\"的节点的标签替换为"",错误就会消失。在


Tags: 文件nodeget节点错误line标签dot

热门问题