Is there a way to output the numbers only from a python list?

后端 未结 10 1418
情歌与酒
情歌与酒 2020-12-11 02:15

Simple Question:

list_1 = [ \'asdada\', 1, 123131.131, \'blaa adaraerada\', 0.000001, 34.12451235265, \'stackoverflow is awesome\' ]

I want

10条回答
  •  温柔的废话
    2020-12-11 02:36

    >>> [ i for i in list_1 if not str(i).replace(" ","").isalpha() ]
    [1, 123131.13099999999, 9.9999999999999995e-07, 34.124512352650001]
    

提交回复
热议问题