将列表中的字符类型转换为整数

2024-10-06 16:22:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我把这些数据转换成整数

['8737', '5330', '7463']
['690', '7227']
['4043', '1572']
['8334', '3227', '5642']
['3705', '3522']

我使用枚举来完成它:

for index, item in enumerate(list_a):
list_a[index] = int(item)

有其他方法来完成它吗?我试着用sting.atoi()来完成它,但它只能将字符串转换成整数


Tags: 数据方法字符串inforindex整数item