| d = open('app/ui.py', 'rb').read() | |
| # [` " ' ] = 5b 60 22 27 5d -> [` " ] = 5b 60 22 5d | |
| old_cc = bytes([0x5b, 0x60, 0x22, 0x27, 0x5d]) # [`"'] | |
| new_cc = bytes([0x5b, 0x60, 0x22, 0x5d]) # [`"] | |
| count = d.count(old_cc) | |
| print(f'occurrences of [`"\']: {count}') | |
| d2 = d.replace(old_cc, new_cc) | |
| open('app/ui.py', 'wb').write(d2) | |
| print('written, size:', len(d2)) | |
| # Verify | |
| d3 = open('app/ui.py', 'rb').read() | |
| i = d3.find(b'createMatch = text.match') | |
| end = d3.find(b'\r\n', i) | |
| print('new line:', repr(d3[i:end])) | |