[英]Print personalized scientific notation in Python
The question is simple: If I have a number x = 2.8e-11
and I want to print it in this format: 2.8 · 10^(-11)
, what should I do?问题很简单:如果我有一个数字x = 2.8e-11
并且我想以这种格式打印它: 2.8 · 10^(-11)
,我应该怎么做?
Thank you in advance.先感谢您。
I would just do this with string operations.我只会用字符串操作来做到这一点。
>>> x = 2.8e-11
>>> if 'e' in str(x):
print(str(x).replace('e', ' · 10^(') + ')')
2.8 · 10^(-11)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.