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



给定以下变量:

fsw="M543x620S30006482x483S14c10520x483S14c51498x537S14c39492x593S20500496x582S22a04494x564"

如果我这样做:

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

它返回:

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

但我想([[482,483],[520,483],...])获得整数对的列表。有没有单行可以执行此操作?

谢谢。

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

最新更新