📅  最后修改于: 2022-03-11 14:47:05.028000             🧑  作者: Mango
def conv(s):
try:
s=float(s)
except ValueError:
pass
return s
print [conv(s) for s in ['1.1','bls','1','nan', 'not a float']]
# [1.1, 'bls', 1.0, nan, 'not a float']