我有以下代碼:在JSON有效載荷中傳遞變量?
import requests
import time
orderID = time.strftime("%#d%m%y") + str(randint(10, 99))
payload = '{ "id": 62345, "shippingCharge": 0.0, "giftCharge": 0.0, "amountDue": 13000.0}'
url = "test.com/v1/%s".format(orderID)
s = requests.Session()
s.headers.update({'Content-Type': 'application/json'})
r = s.post(url , payload, auth=('test01', 'test01'))
我想通過在下面的可變orderID
:
- 如JSON有效載荷
id
字段的值。 - 在URL字符串
v1
後
請幫助我。
請發表您的實際代碼。這是無效的 – e4c5
編輯問題 – e4c5
http://stackoverflow.com/help/how-to-ask – e4c5