Code.GeekInterview.com
 
Code Samples Python
 

Python Script Strings Basic


Code ResourceAuthor: ramamoorthymsc  

Difficulty Level: Beginner

Published: 7th Apr 2010   Read: 3097 times  

Filed in: Python
Add Comment


 

 

Sponsored Links


 

 

Python Script String Basic:

 


Sample Code
  1. #!/python26/python
  2. print "Content-type: text/htmln"
  3. #-----------------------------
  4. mystr1 = "wwn"   # a newline character
  5. mystr2 = r"n"  # two characters,  and n
  6. #-----------------------------
  7. mystr3 = "Jon 'Maddog' Orwant"  # literal single quote inside double quotes
  8. mystr4 = 'Jon "Maddog" Orwant'  # literal double quote inside single quotes
  9. #-----------------------------
  10. mystr5 = 'Jon 'Maddog' Orwant'  # escaped single quote
  11. mystr6 = "Jon "Maddog" Orwant"  # escaped double quote
  12. #-----------------------------
  13. mystr7 = """
  14. This is a multiline string literal
  15. enclosed in triple double quotes.
  16. """
  17. mystr8 = '''
  18. And this is a multiline string literal
  19. enclosed in triple single quotes.
  20. '''
  21. #-----------------------------
  22.  
  23. print mystr1,""
  24. print mystr2,""
  25. print mystr3,""
  26. print mystr4,""
  27. print mystr5,""
  28. print mystr6,""
  29. print mystr7,""
  30. print mystr8,""
  31.  
Copyright GeekInterview.com


Next Article: ASCII value for IP address


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

Time Display python program
import datetime
sri=datetime.datetime.now()
print sri.strftime(%T,%D)
Comment posted by: SRI on 2010-09-25T00:29:38

Popular Coders

# Coder NameHits
1. josephdinesh4467
2. ramamoorthymsc3098

Active Coders

# Coder NameCodes
1. josephdinesh1
2. ramamoorthymsc1

Refined Tags