gpt4 book ai didi

python - 名称错误 : name 'urllib' is not defined "

转载 作者:太空狗 更新时间:2023-10-29 23:57:28 25 4
gpt4 key购买 nike

代码:

import networkx as net
from urllib.request import urlopen
def read_lj_friends(g, name):
# fetch the friend-list from LiveJournal
response=urllib.urlopen('http://www.livejournal.com/misc/fdata.bml?user='+name)

错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined

最佳答案

你已经直接导入了 urlopen,所以你应该这样引用它而不是通过 urllib:

response = urlopen('...')

关于python - 名称错误 : name 'urllib' is not defined ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42314025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com