混合列表理解的字符拆分和int()转换...?

问题描述 投票:-1回答:1

给出以下变量:

fsw="M543x620S30006482x483S14c10520x483S14c51498x537S14c39492x593S20500496x582S22a04494x564"

如果我这样做:

z=[sub.split('x') for sub in re.findall("\d{3}x\d{3}",fsw[8:])] 

它返回:

[['482', '483'],  ['520', '483'],   ['498', '537'], ['492', '593'], ['496', '582'], ['494', '564']]

但是我想得到一对成对的[[integers ([[482,483],[520,483],...])。是否有单线可以执行此操作?

谢谢。
python list int
1个回答
0
投票
z=[map(lambda x: int(x), sub.split('x')) for sub in re.findall("\d{3}x\d{3}",fsw[8:])]
© www.soinside.com 2019 - 2024. All rights reserved.