Python 整个方程的计算器

Python Calculator for whole equation

我正在尝试在 python 中制作一个计算器,但我无法弄清楚如何将整个方程作为输入然后求解。 (X+Y)*Z 其中 x、y、z 是数字

使用python的内置函数eval。例如。 https://docs.python.org/2/library/functions.html#eval

>>> x = 1
>>> print eval('x+1')
2