path='/home/loading/image/img'+str(self.username)+'.jpg'
imgurl=http://i.meizitu.net/thumbs/2016/07/68989_12a19_236.jpg
cmd=("wget -P -N -o -c{0}{1}".format(path,imgurl))
ref=subprocess.call(cmd,shell=True)
if ref!=0:
print "can't get url"
修改后的相应代码cmd =(“wget -P -N -o -c {0} {1}”。format(path,imgurl))
path
和imgurl
没问题,我已经通过urlretrieve的python libraty确定了它,但现在打印“无法获取url”无法下载图片!
答案 0 :(得分:1)
你在'-c'之后忘了一个空格,并且路径和imgurl的顺序可能不正确,因为'http://'通常是网址的开头: - )
path='/home/loading/image/img'+str(self.username)+'.jpg'
imgurl='http://i.meizitu.net/thumbs/2016/07/68989_12a19_236.jpg'
cmd=("wget -P -N -o -c {1}{0}".format(path,imgurl))
ref=subprocess.call(cmd,shell=True)
if ref!=0:
print "can't get url"