小白随手记录改bug过程
if G.nodes[node] == source:
print(type(G.nodes[node]))
开始的代码,报错如标题,分析应该是将一个值与多个值或一个列表中的值相比较、匹配的原因,source是一个列表有多个值,遂改成如下
if G.nodes[node] in source:
print(type(G.nodes[node]))
然后又报错,TypeError: unhashable type: 'dict',于是考虑把字典的数据类型转成字符串
if str(G.nodes[node]) in source:
print(type(G.nodes[node]))
程序不报错了,运行成功