我用下面的方法调用一个url,在调用它的时候需要传递year/month/day作为变量 最后的url结构是
http://mywebiste.com/downloading/main/2016/03/28/'
这是我的密码
import pycurl
import os, sys, re, shutil
import datetime
import time
import requests
import datetime
import logging
import httplib
#logging.basicConfig(level=logging.DEBUG)
httplib.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
now = datetime.datetime.now()
year = now.year
month = now.month
day = now.day
url = 'http://mywebiste.com/downloading/main/%s/%s/%s/'
r = requests.get(url,timeout=10)
r.text
r.status_code
r.connection.close()
我想你想要这个:
再解释一下:对于每个要与
%
一起使用的字符串,您需要将字符串用作my_string = 'my value is: %s' % value
,其中value是您的变量。在相关问题 更多 >
编程相关推荐