Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://stackoverflow.com/a/9773142
- def split_iter(string: str, divider: str) -> Generator[str, None, None]:
- div_size = len(divider)
- start = 0
- while True:
- idx = string.find(divider, start)
- if idx == -1:
- yield string[start:]
- break
- yield string[start:idx]
- start = idx + div_size
Advertisement
Add Comment
Please, Sign In to add comment