Split a string and keep the delimiters as part of the split string chunks, not as separate list elements
问题 This is a spin-off from In Python, how do I split a string and keep the separators? rawByteString = b'\\!\x00\x00\x00\x00\x00\x00\\!\x00\x00\x00\x00\x00\x00' How can I split this rawByteString into parts using "\\!" as the delimiter without dropping the delimiters, so that I get: [b'\\!\x00\x00\x00\x00\x00\x00', b'\\!\x00\x00\x00\x00\x00\x00'] I do not want to use [b'\\!' + x for x in rawByteString.split(b'\\!')][1:] as that would use string.split() and is just a workaround, that is why this