阿里巴巴测开编程题:python 将列表中的字符串转为数字

有一个数字字符的列表:

numbers = ['1', '5', '10', '8']
 
想要把每个元素转换为数字:

numbers = [1, 5, 10, 8]
new_numbers = [];
for n in numbers:
  new_numbers.append(int(n));
numbers = new_numbers;

简单点

numbers = [ int(x) for x in numbers ]
日行一善, 日写一撰
原文地址:https://www.cnblogs.com/xiyuan2016/p/14327700.html