如何在python中字符串拆分数字

时间:2021-04-27 21:41:27

This is what I have, but I know it is incorrect and I'm not sure what to change

这就是我所拥有的,但我知道这是不正确的,我不知道该改变什么

print '0.4066145E-07-0.3677403'.split('E+(\-\d{2})', 1 )

I'm looking to get:

我想得到:

['0.4066145E-07','-0.3677403']

or more generally I just want to split up these numbers.

或者更一般地说我只想分开这些数字。

['######E-##','#########']

Also what if there is an exponent in the second number?

如果第二个数字中有指数,该怎么办?

['######E-##','#######E-##']

1 个解决方案

#1


2  

You can try with:

您可以尝试:

(?<=E-\d\d)(?=-\d+.)

DEMO

DEMO

#1


2  

You can try with:

您可以尝试:

(?<=E-\d\d)(?=-\d+.)

DEMO

DEMO