1 什么是代碼,什么是寫代碼
現(xiàn)實世界事物在計算機(jī)世界中的映射
2 數(shù)字:整型與浮點(diǎn)型
將現(xiàn)實世界中的事物用計算機(jī)語言來描述
int
float
type(1)
type(1.1)
type(1+1)
type(1+1.0)
type(2/2) //float
type(2//2) //int 整除(只保留整數(shù)部分)
3 10柱蟀、2屎即、8、16進(jìn)制
16進(jìn)制表示
0,1,2,3,4,5,6......9,A,B,C,D,E,F,10
4 各個進(jìn)制的表示與轉(zhuǎn)換
進(jìn)制表示
- 0b 二進(jìn)制
- 0o 8進(jìn)制
- 0x 16進(jìn)制
進(jìn)制轉(zhuǎn)換
- bin() 轉(zhuǎn)2
- oct() 轉(zhuǎn)8
- hex() 轉(zhuǎn)16
- int() 轉(zhuǎn)10
5 number 數(shù)字:布爾類型與復(fù)數(shù)
布爾類型
復(fù)數(shù)【pass】
6 字符串:單引號與雙引號
str 字符串
單引號著角、雙引號揪漩、三引號
type('1')
"let's go"
7 多行字符串
tag:每行代碼長度不超過79
'''
hello world
hello world
'''’
"""
hello world
hello world
"""
'hello
world'
print("""hello world\nhello world""")
8 轉(zhuǎn)義字符
無法“看見”的字符
與語言本身語法沖突
\n
'
\t
9 原始字符串
print(r'c:\north\east') 原始字符串,所見即所得
10 字符串運(yùn)算一
"hello"*3 = "hellohellohello"
"hello world"[0] = 'h'
"hello world"[-1] = 'd'
11 字符串運(yùn)算二(切片)
// 角標(biāo)第一個數(shù)字表示起始位置吏口,第二個表示結(jié)束位的下一位
"hello world"[0:5] = 'hello'
"hello world"[0:-1] = 'hello worl'
12 字符串運(yùn)算三
// 第二位留空表示截取到末尾`
"hello world"[6:] = 'world'