使用map函数
python3.x,map返回的是map对象,当然也可以转换为List:
list1 = list(map(int, list1))
去除空格元素:
list1 = [x for x in list1 if x!=‘ ‘]
Python中列表元素转为数字以及去掉空格元素的方法
原文:https://www.cnblogs.com/rtyxxy/p/12809701.html