Python学习第四天记录
Python学习4根据笨方法学Python3进行练习学习,主要记录自己的学习历程和期间遇到的问题。
练习10.那是什么tabby_cat = "tI'm tabbed in." persian_cat = "I'm splitnon a line." backslash_cat = "I'm \ a \ cat." fat_cat = """ I'll do a list: t* Cat food t* Fishies t* Catnipnt* 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
下面的表列出了Python支持的所有转义序列。
| 转义字符 | 功能 |
|---|---|
| \ | 反斜杠() |
| ’ | 单引号(’) |
| ” | 双引号(") |
| a | ASCII响铃符(BEL) |
| b | ASCII退格符(BS) |
| f | ASCII进纸符(FF) |
| n | ASCII换行符(LF) |
| N{name} | Unicode 数据库中的字符名,其中name 是它的名字,仅Unicode 适用 |
| r | ASCII回车符(CR) |
| t | ASCII水平制表符(TAB) |
| uxxxx | 值为16 位十六进制值xxxx 的字符 |
| uxxxxxxxx | 值为32 位十六进制值xxxxxxxx 的字符 |
| v | ASCII垂直制表符(VT) |
| ooo | 值为八进制值ooo 的字符 |
| xhh | 值为十六进制值hh 的字符 |
print("How old are you?", end=' ')
age = input()
print("How tall are you?", end=' ')
height = input()
print("How much do you weight?", end=' ')
weight = input()
print(f"So, you're {age} old, {height} tall and {weight} heavy.")
运行结果
How old are you? 7
How tall are you? 8
How much do you weight? 9
So, you’re 7 old, 8 tall and 9 heavy.
end= ’ ’ 告诉print不要用换行符结束这一行跑到下一行去
eg. print(“How old are you?”)
age = input()
How old are you?
7



