简体   繁体   English

复数计算器

[英]Complex numbers calculator

So, if I type (4*9j**2) into the console, it returns (-324+0j) Is there any way to re-create this with code, basically, take input and simplify it as if you just typed it into the console (j acts as the imaginary number i) 因此,如果我在控制台中键入(4 * 9j ** 2),它将返回(-324 + 0j)是否有任何方法可以使用代码重新创建此代码,基本上,请像输入它一样进行输入并简化它进入控制台(j代表虚数i)

Thanks in advance! 提前致谢!

You can use the built in function eval() . 您可以使用内置函数eval()

>>> 4*9j**2
(-324+0j)
>>> equation = "4*9j**2"
>>> eval(equation)
(-324+0j)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM