Python學習筆記1 內建物件介紹

2021-08-04 21:52:09 字數 826 閱讀 8713

1.數字

1234,3.14,3+4j

ps:不用去宣告變數名及其型別。

2.字串

'asdsa', "i'm meliodas.", "'she said "hello" to you.'"

3.列表

[1,2,3],['a','b','c'],[1,2,[3,4]],[1,'a',[3,'t']]

ps: python中沒有二維陣列,若需要簡單地用到二維陣列,除了物件導向程式設計,還可以用到「列表裡的列表」這個小技巧來實現,如:

4.字典

.5.元組

(2,5,6)

6.檔案

f=fopen('information.txt','w')

7.集合

set('abc'),

8.布林型

true,false

9.空型別

none

10.程式設計單元型別

函式def 函式名([引數列表]):

「『注釋』」

函式體

def sum(a,b):

c=a+b

print c

sum(1,3)

類class關鍵字後加乙個空格,然後是類的名字,然後冒號,最後換行並定義類的內容,即:

calss array:

類的內容

內建物件學習1

感謝顏群老師的指點,博主特別喜歡他,感覺乾貨滿滿,分享給大家 提供的方法 void addcookie cookie cookie 服務端向客戶端增加cookie物件 void sendredirect string location throws ioexception 頁面跳轉的一種方式 重定向...

1 內建物件

一 math物件 1 絕對值 math.abs 2 三個取整方法 math.floor 地板 向下取整 往小了取值 math.ceil 天花板 向上取整 往大了取值 math.round 四捨五入 其他數字都是四捨五入,但是 5 特殊,它往大了取值 例 math.round 1.5 1 math.r...

Python 內建的object物件 1

新式類都有乙個 new 的靜態方法,它的原型是object.new cls cls是乙個類物件,當呼叫c args,kargs 來建立乙個類c的例項時,python的內部呼叫是 c.new c,args,kargs 然後返回值是類c的例項c 確認c是c的例項後 python再呼叫c.init c,a...