小编ufi*_*ufi的帖子

列表列表,将所有字符串转换为int,Python 3

我试图将大列表中的小列表的所有元素转换为整数,所以它应该如下所示:

current list:
list = [['1','2','3'],['8','6','8'],['2','9','3'],['2','5','7'],['5','4','1'],['0','8','7']]


for e in list:
    for i in e:
        i = int(i)

new list:
list = [[1,2,3],[8,6,8],[2,9,3],[2,5,7],[5,4,1],[0,8,7]]
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么这不起作用并向我展示一种有效的方法?谢谢!

python int list type-conversion python-3.x

2
推荐指数
1
解决办法
2511
查看次数

标签 统计

int ×1

list ×1

python ×1

python-3.x ×1

type-conversion ×1