擅长:python、mysql、java
<p>根据问题中的评论,每个单子上都有一个数字。下面是使用<a href="https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions" rel="nofollow noreferrer">list comprehensions</a>进行转换的简单方法:</p>
<pre><code>lst = [198]
[int(x) for x in str(lst[0])]
=> [1, 9, 8]
</code></pre>
<p>要将我的解决方案扩展到包含更多元素的列表(这不是问题中的要求,但见鬼的是):</p>
<pre><code>lst = [198, 199, 200]
[[int(x) for x in str(y)] for y in lst]
[[1, 9, 8], [1, 9, 9], [2, 0, 0]]
</code></pre>