-->

Thursday, February 13, 2014

How to extract a floating number from a string in Python

print i_filename[0]
print re.findall('([-+]?\d*\.?\d+|\d+)',i_filename[0])

40.4223_-3.6834_270_236.29_-28__LgdREJG-S1wk32gQc7OZA.jpg
Out[37]:
['40.4223', '-3.6834', '270', '236.29', '-28', '1', '32', '7']

Credits to Miku

No comments:

Post a Comment