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
网友评论