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

1、字符串公式是有效的

a = ‘3+4’

2、使用eval函数

print(eval(a))

posted @ 2020-03-28 10:33  朱小勇  阅读(2724)  评论(0编辑  收藏  举报