Converting integer to digit list

前端 未结 10 1088
渐次进展
渐次进展 2020-11-30 23:45

What is the quickest and cleanest way to convert an integer into a list?

For example, change 132 into [1,3,2] an

10条回答
  •  独厮守ぢ
    2020-12-01 00:12

    Use list on a number converted to string:

    In [1]: [int(x) for x in list(str(123))]
    Out[2]: [1, 2, 3]
    

提交回复
热议问题