NameError: name 'urllib' 未定义 [英] NameError: name 'urllib' is not defined "
本文介绍了NameError: name 'urllib' 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码:
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
:
You've imported urlopen
directly, so you should refer to it like that rather than via urllib
:
response = urlopen('...')
这篇关于NameError: name 'urllib' 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文