说明:
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()