接口入参格式处理下

“”
斗地主游戏对局开始锁定积分接口
对接口入参做json及base64转化后,调用接口,入参要求如下
{
“member_ids”: “{[2,3,4]}”,
“record_number”: 175,
“division_id”: 3
}
“”"
import json
import base64
import requests
x=json.dumps("{[2,3,4]}")
z=json.loads(y)
q=json.dumps(z)
a={“member_ids”:q,“record_number”:XXX,“division_id”:XXX}
print(a)
encodestr = base64.b64encode(str(a).encode(‘utf-8’))
print(str(encodestr,‘utf-8’))
url = “http://XXX”
payload =str(encodestr)
headers = {
‘Content-Type’: “application/x-www-form-urlencoded”,
}
response = requests.request(“POST”, url, data=payload, headers=headers)
print(response.text)

你可能感兴趣的:(python自动化测试)