473,399 Members | 2,858 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,399 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 92422
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.