Python(新手):如何使用导入的函数进入我的函数?

rea*_*ebo 0 python urllib

此代码无效

import urllib

def loadHtml (url):
    response = urllib.open(url)
    html = response.read()
    return html

firstUrl = 'http://www.google.it';
html = loadHtml (firstUrl);
Run Code Online (Sandbox Code Playgroud)

这是错误

File "af1.py", line 10, in <module>
    html = loadHtml (firstUrl);
File "af1.py", line 5, in loadHtml
    response = urllib.open(url)
Run Code Online (Sandbox Code Playgroud)

我正处于python的第二天......现在的问题是什么?

AttributeError: 'module' object has no attribute 'open'
Run Code Online (Sandbox Code Playgroud)

编辑:我没有在urllib中搜索open是因为我不理解'module'对Python的意思

Ale*_*xey 5

也许urllib.urlopen()是你需要的,不是urllib.open()吗?

您可以在库中找到更多文档: