《笨办法学Python3》练习十:那是什么?
2019-03-01 本文已影响0人
雨开Ame
练习代码
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)
Study Drills
- Memorize all the escape sequences by putting them on flash cards.
- Use ''' (triple-single-quote) instead. Can you see why you might use that instead of """?
- Combine escape sequences and format strings to create a more complex format.
补充
![](https://img.haomeiwen.com/i15819094/4210cbe292eea382.png)