初識python

Python基本數據類型:
int,float,bool,str
值引用和地址引用
int,str,tuple不可改變類型
list, set,dict 可更改類型
具體表現:
不可改變類型:從新賦值變量內容後,變量內存地址變化
可改變類型:從新賦值變量內容後,變量內存地址不變測試

運算符:
1.算術運算符: %,**,+,-,*,/, //
2.賦值運算符: +=,-=, *=, /=, //=
3.比較運算符: ==, >, <, !=,
4.邏輯運算: 參與運算的自己是布爾類型,返回的也是布爾類型,and, or, not
5.身份運算符:is / is not
6.類型判斷: isintance (能夠判斷子類與父類的關係
7.位運算符 &按位與 | 按位或 ^按位異或 ~去反 << 左移 >> 右移
按照二進制的方式進行位運算
type 查看數據類型
isinstance 也會查看數據類型
流程控制(Flow Control)
if-elif-else語句內存

if condition:
//todo 語句
else:
//todoit

if condition:
//todo
elif condition:
//todo
elif condition:
//todo
else:
//todo
for循環
for i in range(2,20,2):
如下是列表,字典,元組表示方式
lists = ["hello", "world", "test", "Redhat"]
dicts = {"Pason": "123@qq.com", "Mike": "mike@163.com"}
tuple_t = (1,True,"Linux")
如下是字典的引用
for item in dicts:
print(item)
print(dicts[item])
如下是各關鍵字
break; continue; pass
如下是測試id的命令
a = (1, 2, 3)
print(hex(id(a)))io

相關文章
相關標籤/搜索