Python:具有多个条件的列表理解

use*_*629 1 python

我有:

s=  'Lot Size: 1.52 acres'
Run Code Online (Sandbox Code Playgroud)

我只想返回一个浮点数(1.52)

我试过了:

>>> o =[s for s in str.split('') if s.isdigit() if s=='.']
>>>

>>>o
>>>[]
Run Code Online (Sandbox Code Playgroud)

我该如何工作?

Sco*_*ter 5

这将分配给o其中的“单词”列表,该列表msg可以解释为浮点数:

def isFloat(n):
    try:
        return float(n)
    except:
        return None

o = list(filter(isFloat,msg.split()))
Run Code Online (Sandbox Code Playgroud)