美文网首页
数字分割

数字分割

作者: 圈圈55 | 来源:发表于2020-07-17 21:21 被阅读0次

    from itertools import groupby

    s = 'Chevrolet3986_small.jpg'

    print(s)

    ss = [''.join(list(g)) for k, g in groupby(s, key=lambda x: x.isdigit())]

    print(ss[0])

    print(ss[1])

    print(ss[2])

    ————————————————

    >>> s = 'Chevrolet3986_small.jpg'

    >>> ss = [''.join(list(g)) for k, g in groupby(s, key=lambda x: x.isdigit())]

    >>> print(ss[0])

    Chevrolet

    >>> print(ss[1])

    3986

    >>> print(ss[2])

    _small.jpg

    >>>

    参考https://blog.csdn.net/qq_24671941/article/details/84071960

    相关文章

      网友评论

          本文标题:数字分割

          本文链接:https://www.haomeiwen.com/subject/wcinhktx.html