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
I'm tabbed in. I'm split on a line. I'm \ a \ cat. I'll do a list: * Cat food * Fishies * Catnip * Grass
print "You can't use both ' and " in string."
File "<ipython-input-2-25192d178d42>", line 1 print "You can't use both ' and " in string." ^ SyntaxError: EOL while scanning string literal
print "You can't use both ' and \" in string."
print 'You can\'t use both \' and " in string.'
print "You can't use both \' and \" in string."
You can't use both ' and " in string. You can't use both ' and " in string. You can't use both ' and " in string.
更多转义符号参见这里.