python標準資料型別叮叮叮

2021-10-11 22:09:35 字數 1446 閱讀 2700

'''

'''python3 六個標準資料型別

1.number(數字)

2.string(字元)

3.list(列表)

4.tuple(元組)

5.set(集合)

6.dictionary(字典)

'''#1.number型別

'''1

.int

(整數)122

.float

(浮點)

14.13.

bool

(布林)

true

,false4.

complex

(複數)4+

3jps: 檢視型別:

type()

isinstance()

區別:type

()不會認為子類是一種父類型別。

isinstance

()會認為子類是一種父類型別。

'''a = 12

b = 14.1

c = true

d = 4+3j

print(type(a)) #print(type(b)) #print(type(c)) #print(type(d)) #print(isinstance(a,int)) #true

print(isinstance(b,float)) #true

print(isinstance(c,bool)) #true

print(isinstance(d,complex)) #true

#2.string型別

e = "name"

print(type(e))

print(isinstance(e,str))

#3.list型別

f = [1,2,3,4,5]

print(type(f))

print(isinstance(f,list))

#4.tuple型別

'''ps: 元組和列表的區別:元組的元素無法修改

'''g =

('abc',24

,2.3

)print

(type

(g))

print

(isinstance

(g,tuple))

#5.set集合

sites =

print

(type

(sites)

)print

(isinstance

(sites,

set)

)#6.dictionary字典

dicte =

print

(type

(dicte)

)print

(isinstance

(dicte,

dict

))

python 標準資料型別

資料型別 set number string list tuple dict bool 標準資料型別 none number string bool 1.none 主要為了判斷存在與否 2.number int long float complex id 查詢記憶體位址 type 查詢資料型別 3....

Python 標準資料型別

python中存在 數字 字串 列表 元組 字典 集合 集合不常用 資料型別。數字資料型別,包括整數 浮點數 複數和布林型別。整數 int 長整型 包括正數,負數,0。浮點數 float 浮點型 帶有小數點的實數。複數 complex 複數由 實部和虛部組成,例 3 4j 或 3 4j 虛部的 j ...

Python標準資料型別 數字型別

python3中標準資料型別有 數字 number 字串 string 列表 list 元組 tuple 集合 set 字典 dictionary 其中不可變資料有3個 數字 number 字串 string 元組 tuple 可變資料有2個 列表 list 集合 set 字典 dictionary...