我有以下python列表:
x = ["56843", "84631", "13831"]
我想获得以下列表:
x = [ ["5","6","8","4","3"] , ["8","4","6","3","1"] ]
我该如何实现?
我尝试过使用split,但是我需要一个不知道是哪个分隔符
答案 0 :(得分:2)
就这样:
x = [list(y) for y in x]
list(y)
(其中y
是字符串)会将字符串转换为字符列表。
答案 1 :(得分:0)
x = [[ch for ch in s] for s in x]
答案 2 :(得分:0)
x = ["56843","84631","13831"]
c = []
for i in x:
c.append(list(i))
print(c)