3 Python資料型別

2021-09-20 09:50:56 字數 563 閱讀 2118

用於存貯各種不同型別的資料

標準資料型別

釋義numbers

數字string

字串list

列表tuple

元組dictionary

字典1.numbers - python的4種不同的數字資料型別

用於存貯數值

數字資料型別

釋義int

有符號整型

long

長整型(python使用 l 來顯示長整型,防止混淆象形數字)[也可以代表八進位制和十六進製制]

float

浮點型complex

複數2. python字串 - string

3. python列表 - list

列表使用標識,是最通用的復合資料型別,是有序的物件集合。

4. python元組 - tuple

5. python元組 - dictionary

除list外,python中最靈活的內建資料結構型別。是無序的物件集合。

轉換函式

描述complex(real [,imag])

建立乙個複數

3 Python的結構資料型別

元組 字典 列表示例 lst 1,2,3,hello 12.55,python print lst print lst 2 lst 4 555 print lst lst lst 1,2,3 print lst lst lst 2 print lst 執行結果 1,2,3,hello 12.55,p...

Python資料型別 3

1.集合 集合是乙個無序且無重複元素的資料組合,它的主要作用如下 1 去重,當把乙個列表變成集合時,就自動去重了 2 關係測試,測試兩組資料之間的交集 差集以及並集等資料關係。list 1 1,2,4,7,3,4,7,9 set 1 set list 1 print set 1,type list ...

python3資料型別

一 python可以自定義資料型別,預設的資料型別有 1 int 整數 2 float 浮點數 3 complex 複數 4 bool 布林值 5 str 字串 6 list 列表 7 tuple 元組 8 set 集合 9 dict 字典 type 內建函式,可以檢視變數的資料型別 int 整數 ...