1、字符串公式是有效的
a = ‘3+4’
2、使用eval函数
print(eval(a))
python处理字符串类型的公式并计算结果
原文:https://www.cnblogs.com/judes/p/12586131.html