Python/Django: Creating a simpler list from values_list()

后端 未结 4 1750
深忆病人
深忆病人 2020-12-25 11:24

Consider:

>>>jr.operators.values_list(\'id\')
[(1,), (2,), (3,)]

How does one simplify further to:

[\'1\', \'2\',          


        
4条回答
  •  囚心锁ツ
    2020-12-25 11:55

    Something like this?

    x = [(1,), (2,), (3,)]
    y = [str(i[0]) for i in x]
    ['1', '2', '3']
    

提交回复
热议问题