skumar
skumar

Reputation: 21

After split why is it adding \t here and \x08? How to avoid this conversion?

>>> output = "10.1.1.2\11.1.1.2$11.1.1.2\10.1.1.2"
>>> output.split("$")
['10.1.1.2\t.1.1.2', '11.1.1.2\x08.1.1.2']

Upvotes: 2

Views: 270

Answers (1)

hobbs
hobbs

Reputation: 240030

Split isn't adding anything, you are. \11 is character octal 11 (decimal 9), which is tab. \10 is character octal 10 (decimal 8), which is usually written \x08. They're already in output before the split.

If you want backslashes in your string, write them as \\, or use a raw string, r"10.1.1.2\11.1.1.2$11.1.1.2\10.1.1.2".

Upvotes: 5

Related Questions