可以在请求中使用可变数量而不是' 201804101602 (python 3)?
import requests
url = "http://127.0.0.1:8080/school/class201804101456"
headers = {'name': 'tom201804101456'}
response = requests.request("GET", url, headers=headers)
print(response.text)
答案 0 :(得分:0)
因为它们只是字符串,为什么不设置变量然后将它附加到上面的示例中的类和tom?
例如:
import requests
token = "201804101456"
url = "http://127.0.0.1:8080/school/class" + token
nameHeader = "tom" + token
headers = {'name': nameHeader}
response = requests.request("GET", url, headers=headers)
print(response.text)