1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| # 试试变量 x = 3 print(x) 幸运数 = 1997 print(幸运数) name = 'yixin' print(name) # 试试基本的数据类型 # 整数(int) 浮点型(float) 字符串(str) 布尔值(bool) # 1, 空(NoneType some = None print(type(some)) # 2, 布尔型(bool) some = True print(type(some)) # 3,整形(int) some = 12345 print(type(some)) # 4,浮点型(float) some = 12.345 print(type(some)) # 字符串(str) some = 'abc' print(type(some)) print(type(8)) counter = 100 # 整型变量 miles = 1000.0 # 浮点型变量 name = "runoob" # 字符串 print(counter) print(miles) print(name) x = 3 y = 5 x,y = y,x print(x,y) # 字符串的特性 # 1,Python中单引号和双引号使用完全相同 m = 'abc' n = "abc" q = (m == n) print(q) # 2,使用三引号 ('''或 ''') some = ''' abc def gbk lll ''' print(some) # 3,转义符’\‘ some = 'abc\n def' print(some) # 4,自然字符串,通过在字符串前加r或者R,可以忽略转义符 some = r'abc\n def' print(some) # 5,python 允许处理unicode字符串,加前缀u或者U
|