【正则表达式应用】不规则多维数组展平一维

l = [[1, 2], [3, 4], [5, [6, 7, [8, 9]]], 10, [11, [12, 13, [14, 15, [16]]]]]

eval(re.sub("(?!^)\[|\](?!$)", "", str(l))) # 小小明

[int(i) for i in re.findall('\d+',str(l))] # 原创

 

 

 原文:

https://blog.csdn.net/as604049322/article/details/112387064

posted @ 2022-06-05 11:20  HuaBro  阅读(38)  评论(0编辑  收藏  举报