Exercise 10: What Was That?

tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\ a \\ cat."
fat_cat = """
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
"""
print tabby_cat
print persian_cat
print backslash_cat
print fat_cat

Escape Sequences

Escape What it does.
\\   Backslash ()
\'   Single quote (')
\"   Double quote (")
\a   ASCII Bell (BEL)
\b   ASCII Backspace (BS)
\f   ASCII Formfeed (FF)
\n   ASCII Linefeed (LF)
\N  {name} Character named name in the Unicode database (Unicode only)
\r   ASCII Carriage Return (CR)
\t   ASCII Horizontal

\u  xxxx Character with 16-bit hex value xxxx (Unicode only)

\U  xxxxxxxx Character with 32-bit hex value xxxxxxxx (Unicode only)
\v    ASCII Vertical Tab (VT)

\ooo Character with octal value ooo
\xhh Character with hex value hh

posted @ 2014-10-22 14:55  林中细雨  阅读(154)  评论(0编辑  收藏  举报