Created
February 25, 2012 04:05
-
-
Save dervn/1906384 to your computer and use it in GitHub Desktop.
python下载网络上的图片示例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import os | |
picurl="http://images.51cto.com/files/uploadimg/20100630/104906665.jpg" | |
save_path="d:\\" | |
imgData = urllib2.urlopen(picurl).read() | |
# 给定图片存放名称 | |
fileName = save_path + "\\ddd.jpg" | |
# 文件名是否存在 | |
if os.path.exists(fileName): | |
output = open(fileName,'wb+') | |
output.write(imgData) | |
output.close() | |
print "Finished download \n" | |
print "运行完成" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment