pycharm中的Python错误urllib.request错误

时间:2015-07-21 21:29:29

标签: python

使用Pycharm运行此代码时出现以下错误

import random
import urllib.request



def download_web_image(url):
    name = random.randrange(1, 1000)
    full_name = str(name) + ".jpg"
    urllib.request.urlretrive(url, full_name)

download_web_image("https://realpython.com/learn/python-first-steps/images/pythonlogo.jpg")

1 个答案:

答案 0 :(得分:0)

你拼写错误的urlretrive -> urlretrieve

 urllib.request.urlretrieve(url, full_name)