472,986 Members | 2,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to print raw string data from a variable

Could someone (anyone) give me a clue how to display all characters stored in a string variable.

For example, if I have a text file containing '1\n2\n3\n'
I read it in with A=file.read()

Now I would like python to print A as 1\n2\n3\n and not
1
2
3

Do I have to convert A to a raw string, or does it already contain raw data that is then processed by the print statement?

Do raw strings exist seperately from 'normal' strings, or is it just a string displayed in its entirety?

Thanks
Jun 29 '07 #1
2 92309
bvdet
2,851 Expert Mod 2GB
Could someone (anyone) give me a clue how to display all characters stored in a string variable.

For example, if I have a text file containing '1\n2\n3\n'
I read it in with A=file.read()

Now I would like python to print A as 1\n2\n3\n and not
1
2
3

Do I have to convert A to a raw string, or does it already contain raw data that is then processed by the print statement?

Do raw strings exist seperately from 'normal' strings, or is it just a string displayed in its entirety?

Thanks
Expand|Select|Wrap|Line Numbers
  1. >>> s = '1\n2\n3\n'
  2. >>> print repr(s)
  3. '1\n2\n3\n'
  4. >>> 
Jun 29 '07 #2
Expand|Select|Wrap|Line Numbers
  1. >>> s = '1\n2\n3\n'
  2. >>> print repr(s)
  3. '1\n2\n3\n'
  4. >>> 
repr() , I've not seen that before

Thanks that's great.
Jun 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: AJ Shankar | last post by:
Hi, In the C API, is there any way to execute a query, store all the results, and somehow find the maximum realized width for each of the fields before fetching each row? Otherwise there is no...
3
by: Konrad Mathieu | last post by:
How do I - within in a function - make Javascript recognize a string as a variable name? Thanks and cheers, Konrad
2
by: semi | last post by:
I am pretty new to using C++ and I can't figure this out. I have class PTM that starts a thread. There is an array of structure to be shared between PTM class and thread function. For some...
6
by: John Aldrin | last post by:
Hi, I'm looking for info that explains the format of a string data type when written to a stream using a BinaryWriter. I've looked all over MSDN and Internet and I cannot seem to find it. I...
0
by: Fritz | last post by:
Hi, My problem is getting a string of variable length from a unmanaged DLL, called by a managed DLL using IJW. In der legacy DLL is declared bool UnmanagerClass::GetData(std::wstring* pString)...
0
by: Ripendra007 | last post by:
hi, Can u tell me how can i print the data of datgrid to next page with header column on next paper ? I hav dataset which contains information of groupwise report and bound to datagrid now i want ro...
3
by: psbasha | last post by:
Hi , When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ). ...
7
Dököll
by: Dököll | last post by:
Hey Gang! I am at work, will attempt to make it brief:-) Looks like I am unable to print subform data results. When the subform loads with the results I want, say from 9,000 records, I get 100...
38
by: ssecorp | last post by:
char* reverse(char* str) { int length = strlen(str); char* acc; int i; for (i=0; i<=length-1; i++){ acc = str; } return acc; }
0
by: Haroon Rafik | last post by:
I need to print preview data on a form (not a file or documen) using the PrintPreviewDialog componenet. I know how to do it using the PrintForm component, but I need to use the PrintPreviewDialog...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.