Q:

Decoding an encoded text file - Python

So suppose I have wrote a method that has encoded a text file into some gibberish that looks like
úÎúÞ<81>i<82>ran<81><83>there<81><84>with<85>carol<86>we<81><87>did
I have 0 sense on how to go about putting back into a normal text file that says 
i ran there with carol we did
the characters at the beginning are just magic numbers but I just want to check the magic numbers and take the words back out into a file ignoring the numbers.

A:

re.split with the right pattern will do it:
import re
s='úÎúÞ<81>i<82>ran<81><83>there<81><84>with<85>carol<86>we<81><87>did'
L = re.split(r'<[\d<>]+>',s)
print(L)
print(' '.join(L[1:]))

Output:
['úÎúÞ', 'i', 'ran', 'there', 'with', 'carol', 'we', 'did']
i ran there with carol we did

