Python将数组值转换为单独的数组

use*_*110 -1 python

我有一个看起来像这样的python数组:[1,2,3,4,5]

我希望它看起来像这样:[[1],[2],[3],[4],[5]]

我该怎么做呢?

谢谢!

Loi*_*icM 5

我假设你在谈论列表.这应该工作:

l = [1, 2, 3, 4, 5]

out = [[i] for i in l]
Run Code Online (Sandbox Code Playgroud)