473,544 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to print raw string data from a variable

6 New Member
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 92437
bvdet
2,851 Recognized Expert Moderator Specialist
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
stygian
6 New Member
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
623
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 way to efficiently retrieve string data. The best you can do is either allocate a static buffer of 64K (max size for a blob) or some smaller buffer...
3
18730
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
2937
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 reason, string data gets lost when it gets to the thread function. ---------- in PTM.h ---------- using namespace std;
6
5744
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 did some simple testing and it seems that the string data is prefixed w/a variable number of bytes that indicate the length. 1 byte if length <=...
0
990
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) { // content of pString as input by the caller is received correct *pString = L"the string to return";
0
1240
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 print those data on paper but when i m printing those data using window.print() it will print all data contineous and i want to print those data...
3
3242
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 ). Please suggest me which is the best way of handling the file data. I- Method: ---------------- Store as single line string data's(upto end of file...
7
2175
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 + out of that. I can't seem to print just the results or preview in a report. I know I've missed something. Searched here did not find anything,...
38
2674
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
1308
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 component. Any suggestions/hints? Thanks.
0
7416
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7360
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7761
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7363
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7701
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5289
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4906
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3400
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1833
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.