def exec_def(cmd_str, obj): import requests print(requests.post("http://172.18.162.173:8000/exec", json={ "function_str": cmd_str, "call_str": "exec(obj)", "param_dict": { "obj": obj } }).json()) # ================[ 自定义部分 Start ]=============== exec_str = """ def exec(obj): import json obj["a"] = 123 return obj """ obj = {"b": 45} # ================[ 自定义部分 End ]=============== exec_def(exec_str, obj)