使用eval()
re = '{\n "path": "/sms/sendMsg",\n "data": {\n "mobile": "12345678901",\n "signCode": "短信签名",\n "templateCode": "SMS_yyyymmdd0",\n "param": {"code": 123456}\n }'
# 遍历json找到有*号的做运算
data = json.loads(re)
for k in data:value = data[k]if "*" in value:data[k] = eval(value)
print(data)
# 只能运算字符串
print(eval("'A' * (50 * 1024 * 1024 + 1)"))