原因为data数据不是json类型,需要使用json.dumps(data)进行格式化,代码如下:
class UserBehavior(TaskSet): @task(1) def interface_1(self): headers = {"Content-Type": "application/json"} url = "/robat/cock/cock" data = { "taskid": "20180703101505551", "uinid": "29007037" } aaa = json.dumps(data) self.client.post(url=url, data=aaa, headers=headers)