gpt4 book ai didi

python - 如何将整数拆分为数字列表?

转载 作者:IT老高 更新时间:2023-10-28 20:22:32 24 4
gpt4 key购买 nike

假设我有一个输入整数 12345。如何将其拆分为 [1, 2, 3, 4, 5] 之类的列表?

最佳答案

>>> [int(i) for i in str(12345)]

[1, 2, 3, 4, 5]

关于python - 如何将整数拆分为数字列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1906717/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com