Python基本資料一

2021-09-24 10:56:40 字數 621 閱讀 1076

變數資料型別0-1

python基本資料型別包括了:數字型別,布林型,字串,列表,元組,字典,集合。

一、檢視資料型別的方法:

type:檢視資料型別

temp = 『hello』

t = type(temp)

print(t)

help,type:檢視資料型別下的全部方式

help(type(temp))

dir:檢視類下全部方法

d = dir(temp)

print(d)

檢視類下某特定方法

temp.upper() # ctrl+滑鼠左鍵單擊upper(),自動定位到upper()方法

數字的型別0-2

一、int(整形)

二 、float(浮點型)

三、complex(複數)

布林型0-3

字串檢視和使用方法

常用方法

索引的取值和切片

第二天筆記

python基本數 python基本資料型別

1.數字 int 數字又分整型和浮點型,在python中宣告變數是不用宣告所以自己就會識別 a 10 整型 a1 1.24 浮點型 支援科學計數法,將10用e來代替 2.字串 str 在python中用引號引起來的就是字串,而且單引號和雙引號並沒有什麼區別 a string a1 string a2...

Python基本資料生成

1.隨機函式的使用 random.random random float x,0.0 x 1.0 0.37444887175646646 random uniform 1,10 random float x,1.0 x 10.0 1.1800146073117523 random.randint 1...

python 基本資料型別之一

int 將字串轉換成數字 a 123a 不能改 a 123 b int a print b print type b 檢視乙個元素的型別 這裡轉換的是ascii值,如果是多個字元就不能轉換了 a b b int b print b 進製轉換,轉換成2進製,num 0011 v int num,bas...