Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中将字符串列表转换为整数列表_Python_List - Fatal编程技术网

如何在python中将字符串列表转换为整数列表

如何在python中将字符串列表转换为整数列表,python,list,Python,List,如果我的名单是 B = ['1,222,000', '234,444', '12,000,000'] 如何将其转换为 [122200023444412000000] 我试过了 B = list(map(int, B) 但它给出了错误 以10为基数的int()的文本无效:“1375178”请先删除逗号,如下所示: B = [int(i.replace(',', '')) for i in B] 您还可以使用正则表达式和映射: import re B = ['1,222,000', '234,

如果我的名单是

B = ['1,222,000', '234,444', '12,000,000']
如何将其转换为

[122200023444412000000]

我试过了

B = list(map(int, B)
但它给出了错误


以10为基数的int()的文本无效:“1375178”

请先删除逗号,如下所示:

B = [int(i.replace(',', '')) for i in B]

您还可以使用正则表达式和
映射

import re
B = ['1,222,000', '234,444', '12,000,000']
new_b = list(map(lambda x:int(re.sub('\W+', '', x)), B))
输出:

[1222000, 234444, 12000000]