说明:

1. 虽然很简单,但总忘,所以还是记下来吧!

2. http://placekitten.com/300/300这个画猫的网站老是打开没有图片,改成了http://placehold.it/300/300这个数字占位图片。

3. 记得用response.read()

 1 import urllib.request
 2 
 3 # <span class="current-comment-page">[1292]</span>
 4 # <img src="//ww2.sinaimg.cn/mw600/7064b124jw1enncg4zsmij20dw0ijgn0.jpg" style="max-width: 480px; max-height: 750px;">
 5 # url = "http://placekitten.com/300/300"
 6 url = "http://placehold.it/300/300"
 7 response = urllib.request.urlopen(url)
 8 img = open("1.jpg","wb")
 9 img.write(response.read())
10 img.close()

 

相关文章:

  • 2021-12-10
  • 2021-11-23
  • 2022-02-21
  • 2022-02-09
  • 2022-12-23
  • 2022-01-01
  • 2021-11-30
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-12-10
  • 2021-11-30
  • 2021-11-26
相关资源
相似解决方案