Converting integer to digit list

前端 未结 10 1087
渐次进展
渐次进展 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:18

    you can use:

    First convert the value in a string to iterate it, Them each value can be convert to a Integer value = 12345

    l = [ int(item) for item in str(value) ]

提交回复
热议问题