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”无法下载图片!
最佳答案
您忘记了“-c”后的空格,并且路径和 imgurl 的顺序可能不正确,因为“http://”通常是 url 的开头:-)
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"
关于python - 在linux OS下使用subprocess fork a process总是下载不了图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44521711/