Python3 中有六個標準的數據類型:
Number(數字)
String(字符串)
List(列表)
Tuple(元組)
Set(集合)
Dictionary(字典)
Python3 的六個標準數據類型中:
不可變數據(3 個):Number(數字)、String(字符串)、Tuple(元組);
可變數據(3 個):List(列表)、Dictionary(字典)、Set(集合)python
整型和浮點型統稱爲數字類型。code
age = 19 # age = int(10) print(type(age))
<class 'int'>
字符串
x = int('111') print(type(x))
<class 'int'>
io
x = int('11.1') # 報錯 print(x)
x = 11111111111111111111111111111111111111111111111
print(type(x)) # longintclass
4.存一個值or多個值:一個值基礎
5.有序or無序:無有序or無序一說List
age = 19 print(f'first:{id(age)}') age = 20 print(f'second:{id(age)}')
first:4384901776
second:4384901808
數據類型
age = 3.1 # age = float(3.1) print(type(age))
<class 'float'>
float
x = float('111') print(x) print(type(x))
111.0
<class 'float'>
方法
x = float('11.1') # 報錯 print(type(x))
<class 'float'>
3.經常使用操做+內置方法:算術運算+比較運算
4.存一個值or多個值:一個值
salary = 3.1 print(f'first:{id(salary)}') salary = 5.1 print(f'second:{id(salary)}')
first:4423173584
second:4423173800
id不變值可變,即在原值的基礎上修改,則爲可變數據類型;值變id也變,即從新申請一個空間放入新值,則爲不可變數據類型。