473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Raw string printing

Hy !

I would like to do something like:

s = r"a\tb\n"

print s
# result with
a\tb\n

print unraw(s) # <= this is the "magic" function I'm searching for
# result with
a b
n

Does any of you know how to do it properly ?

Sep 25 '07 #1
2 1511
Alexandre Badez wrote:
I would like to do something like:

s = r"a\tb\n"
print unraw(s) # <= this is the "magic" function I'm searching for
# result with
a b
n

Does any of you know how to do it properly ?
>>print r"a\tb\nx".decode("string-escape")
a b
x

Peter
Sep 25 '07 #2
On Sep 25, 2:24 pm, Peter Otten <__pete...@web.dewrote:
Alexandre Badez wrote:
I would like to do something like:
s = r"a\tb\n"
print unraw(s) # <= this is the "magic" function I'm searching for
# result with
a b
n
Does any of you know how to do it properly ?
>print r"a\tb\nx".decode("string-escape")

a b
x

Peter
THANKS :D
Sep 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul Rubin | last post by:
How about adding a string interpolation method and a some print methods to strings. 'hello world'.print() => same as "print 'hello world'". With optional fd arg, print to file object 'hello...
5
by: Chris Schumacher | last post by:
I'm working on a program which splits a long string into a series of smaller ones. It is supposed to work as follows; 1. You enter a string into variable "str" 2. The program searches for the...
11
by: jt | last post by:
Here is my code below, it doesn't printf. But I step it thru using the for statement and use putchar to the display, its there... How can I get it to use printf? If the problem is needing a null...
1
by: Hai Ly Hoang | last post by:
Hi, I have string which contains linefeed and carry-return characters (eg. "Banana \r\n Apple \r\n..."); To print this string, i make use of PrintPage event of PrintDocument with DrawString...
3
by: Jimbo | last post by:
Hey Its easy to print a string. You just write: System.Drawing.Printing.PrintPageEventArgs.Graphics.DrawString("This is a string!", new Font("Ariel", 14, FontStyle.Bold), Brushes.Black, 0,...
3
by: Mikael Syska | last post by:
Hi, I'm reading Beginning Visual C-Sharp by wrox, great book by the way. In the book the describe how I can print, and it works great, but what if I has like 300 lines, that wont fit on a...
9
by: Divick | last post by:
Hi all, I have a problem related to std::string class. Is it ok to assign a global string variable to a local string object as shown below? I am trying to print the address of local string...
5
by: Ross | last post by:
I have a quick question regarding printing string constants. When you printf() a string constant, how are the characters encoded that get sent to the standard output? Is it in the execution...
33
by: Bertram Trabant | last post by:
Hello, Im working on a little LAN game in the style of old text-only MUD's and would need to find a way to search for a string in a text file (for example for usernames). I know it works in the way...
0
by: MLH | last post by:
In an earlier post today, it was mentioned that dbl-spaces caused alignment-justification problems when printing labels. I've never noticed this in reports except for those meant for the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.