字符串list
num_list = ['1', '2', '3', '4']
方法1:列表生成式
num_list = [ int(x) for x in num_list ]
方法2:map函数
1.python2.xnum_list = map(int, num_list)2.python3.x,map返回的是map对象,也可以转换为List:num_list = list(map(int, num_list))
时间:2021-08-09 17:45:45
字符串list
num_list = ['1', '2', '3', '4']
方法1:列表生成式
num_list = [ int(x) for x in num_list ]
方法2:map函数
1.python2.xnum_list = map(int, num_list)2.python3.x,map返回的是map对象,也可以转换为List:num_list = list(map(int, num_list))
把数字翻译成字符串python_python中如何将字符串强制转为数字
2022-05-22
python 列表中的数字转字符串_python 将列表中的字符串转为数字
2020-11-08