美文网首页Learn to Code
《笨办法学Python3》练习十:那是什么?

《笨办法学Python3》练习十:那是什么?

作者: 雨开Ame | 来源:发表于2019-03-01 14:34 被阅读0次

练习代码

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

  1. Memorize all the escape sequences by putting them on flash cards.
  2. Use ''' (triple-single-quote) instead. Can you see why you might use that instead of """?
  3. Combine escape sequences and format strings to create a more complex format.

补充

常用转义字符

相关文章

网友评论

    本文标题:《笨办法学Python3》练习十:那是什么?

    本文链接:https://www.haomeiwen.com/subject/kleduqtx.html