471,888 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,888 software developers and data experts.

Backslash substitutions

Hello,

How would you perform backslash substitution in a string, just like the
Python parser does?

Example:
---
s = "\\n"
print s \n print ???(s)
---
where '???' is a function that I wasn't able to find.

Just in case, another example:
--- s = "\\\\A\\tB"
print s \\A\tB print ???(s) \A B

---

Thank you.
Jul 18 '05 #1
1 1237
Vivien Mallet wrote:
How would you perform backslash substitution in a string, just like the
Python parser does?

"\\\\A\\tB".decode("string_escape") '\\A\tB' _.encode("string_escape") # back again

'\\\\A\\tB'

Peter

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tony Eva | last post: by
5 posts views Thread by Aloysio Figueiredo | last post: by
8 posts views Thread by abhishek | last post: by
3 posts views Thread by Stef Mientki | last post: by
2 posts views Thread by Tobiah | last post: by
4 posts views Thread by Razzbar | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.