Advertisement
mengyuxin

meng.processString.py

Dec 30th, 2017
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # processString.py
  2.  
  3. # 双引号
  4. spam = "That is Andy's school bag."
  5. print(spam)
  6.  
  7. # 6.1.3 转义字符
  8. spam = "Hello there!\nHow are you?\nI\'m doing fine."
  9. print(spam)
  10.  
  11. print('\'') #单引号
  12. print('\"') #双引号
  13. print('\t') #制表符
  14. print('\n') #换行符
  15. print('\\') #反斜杠
  16.  
  17.  
  18. # 6.1.4 原始字符串
  19. spam = r'That is Andy\'s iPad.'
  20. print(spam)
  21.  
  22. print('\n')
  23. # 用三重引号的多行字符串
  24. print('''Dear Alice,
  25.  
  26. Eve's cat has been arrested for catnapping, cat burglary, and extortion.
  27.  
  28. Sincerely,
  29. Andy''')
  30.  
  31. # 多行注释
  32. """ This is a test Python program.
  33. Studied by Meng Yuxin emyx@msn.com
  34.  
  35. This program was designed for Python 3 not Python 2.
  36. """
  37.  
  38. def test():
  39.     """This is a multiline comment to help
  40.    explain what the test() function does."""
  41.     print('\nHello')
  42.  
  43. test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement