使用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")
答案 0 :(得分:0)
你拼写错误的urlretrive -> urlretrieve
:
urllib.request.urlretrieve(url, full_name)