如何将整数拆分为数字数组?
问题描述:
我的整数输入假设为12345
,我想将其拆分为1, 2, 3, 4, 5
.
我将如何做到这一点?
My integer input is suppose 12345
, I want to split and put it into an array as 1, 2, 3, 4, 5
.
How will I be able to do it?
答
>>> [int(i) for i in str(12345)]
[1, 2, 3, 4, 5]