[交作业啦]
ex10.py
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)
print("Octal 100 is \100")
print("Hex 40 is \x40")
会话
PS E:\lpthw> python .\ex10.py
I'm tabbed in.
I'm split
on a line.
I'm \ a \ cat.
I'll do a list:
* Cat food
* Fishies
* Catnip
* Grass
Octal 100 is @
Hex 40 is @
PS E:\lpthw>
[学习心得]
1 转义字符\ooo和\xhh的用法,见ex10.py的最后两行