python处理字符串类型的公式并计算结果

1、字符串公式是有效的

a = ‘3+4’

2、使用eval函数

print(eval(a))

猜你喜欢

转载自www.cnblogs.com/judes/p/12586131.html