📌  相关文章
📜  转换字符串范围列表 python 代码示例

📅  最后修改于: 2022-03-11 14:46:29.650000             🧑  作者: Mango

代码示例1
def f(x):
    result = []
    for part in x.split(','):
        if '-' in part:
            a, b = part.split('-')
            a, b = int(a), int(b)
            result.extend(range(a, b + 1))
        else:
            a = int(part)
            result.append(a)
    return result