简体   繁体   中英

Converts the character type in list to an integer

I have these data to convert it to integers.

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

I use enumerate to finish it:

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

Is there other ways to finish it ?I try sting.atoi() to make it ,but it can only converts string to integer.

Sure, you can use map for this.

list_a = list(map(int, list_a)) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM