如何解决单独运行“list(list(commu_gn)[0])”时出错
我的代码的第一个单元格是:
import networkx as nx
from networkx.algorithms import community
import urllib3
import io
http = urllib3.PoolManager()
# Load dataset from Github
url = 'https://raw.githubusercontent.com/leanhdung1994/WebMining/main/lesmis.gml'
f = http.request('GET',url)
data = io.BytesIO(f.data)
g = nx.read_gml(data)
commu_gn = community.centrality.girvan_newman(g)
然后我在单元格下方运行(仅包含 1 行)
list(list(commu_gn)[0])
并得到一个错误:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-17-bda509de10a8> in <module>()
----> 1 list(list(commu_gn)[0])
IndexError: list index out of range
另一方面,在单元格下方运行不会返回错误:
commu_gn = community.centrality.girvan_newman(g)
list(list(commu_gn)[0])
能否请您详细说明一下这个问题?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。