Python 找到字符串中某个字符的所有位置

2019-01-15  本文已影响16人  ElonYanJ

Python 找到字符串中某个字符的所有位置

import re

a = "123123123"
for a in re.finditer('1', '123123123'):
    print(a.span())
(0, 1)
(3, 4)
(6, 7)
上一篇 下一篇

猜你喜欢

热点阅读