提问人:Francis 提问时间:10/31/2022 最后编辑:Andrej KeselyFrancis 更新时间:10/31/2022 访问量:46
将字符串列表转换为整数嵌套列表
Convert a list of strings to a Nested list of integers
答:
4赞
Andrej Kesely
10/31/2022
#1
尝试:
lst = ["0100", "0100"]
out = [[int(ch) for ch in s] for s in lst]
print(out)
指纹:
[[0, 1, 0, 0], [0, 1, 0, 0]]
评论
2赞
flakes
10/31/2022
或者[list(map(int, s)) for s in lst]
评论