I have a string for example:
str1 = "'107.8X98x3.75'"
[107.8, 98, 3.75]
str2 = 'L=130.5mm;L=90mm'
[130.5, 90]
str3 = '圓278.5x15t 304'
[278.5, 15, 304]
I know how to extract by int and float, but I don't want to miss which the numbers appear.
I have a string for example:
str1 = "'107.8X98x3.75'"
[107.8, 98, 3.75]
str2 = 'L=130.5mm;L=90mm'
[130.5, 90]
str3 = '圓278.5x15t 304'
[278.5, 15, 304]
I know how to extract by int and float, but I don't want to miss which the numbers appear.
How about regular expressions?
Example
>>> import re
>>> str1="107.8X98x3.75"
>>> re.findall(r'\d+(?:\.\d+)?', str1)
['107.8', '98', '3.75']