Go Back   The UNIX and Linux Forums > Top Forums > Programming


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-21-2012
Registered User
 
Join Date: Nov 2011
Posts: 26
Thanks: 8
Thanked 1 Time in 1 Post
Python, How to print a character \

In python, if I use '\', error, use "\", error again, use '\\' or "\\", the print result will be \\
If I want to print a single \, what can I do?
Thanks in advance

Sorry... I have solved this problem...
Thanks anyway

Last edited by pludi; 06-21-2012 at 11:02 AM..
Sponsored Links
    #2  
Old 06-21-2012
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,338
Thanks: 143
Thanked 1,754 Times in 1,591 Posts
I get this:

Code:
$ python -c 'print "\\"'
\

What do you get?
Sponsored Links
    #3  
Old 06-24-2012
Registered User
 
Join Date: Jun 2012
Location: London, UK
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Language: Python: Running IDLE from Windows 7 Pro...


Code:
>>> print '\'
SyntaxError: EOL while scanning string literal
>>> print "\"
SyntaxError: EOL while scanning string literal
>>> print '\\'
\
>>> print "\\"
\
>>>


Last edited by Scrutinizer; 06-24-2012 at 08:52 AM.. Reason: code tags
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Print the next ASCII character machomaddy Shell Programming and Scripting 2 01-31-2012 09:02 AM
Print one by one character divya bandipotu Shell Programming and Scripting 7 07-22-2011 10:26 AM
read the text file and print the content character by character.. samupnl Shell Programming and Scripting 1 06-10-2010 03:03 AM
python, character replacement gav2251 Programming 0 02-19-2009 05:58 AM
AWK print a character many times dbrundrett Shell Programming and Scripting 3 06-30-2004 10:43 AM



All times are GMT -4. The time now is 12:08 PM.