Please don't use eval
for anything if you're not acutely aware how unsafe it is. Instead, properly parse your input.
import math
s = '[1.4,2.3,nan]'
x = [float(n) for n in s.lstrip('[').rstrip(']').split(',')]
x = [n for n in x if not math.isnan(n)]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…