import requests cmd_str = """ def exec(obj): obj['name2']=2 obj['name3']=2 return obj """ print(requests.post("http://172.18.162.173:8000/exec", json={ "function_str": cmd_str, "call_str": "exec(obj)", "param_dict": { "obj": { "name": 1 } } }).json()) # 第一个参数:函数字符串 # 第二个参数:函数里的名字和参数 # 第三个参数:入参,以dict形式传递 # 返回值 # {'code': 200, 'res': 6}