【第一課】
1、用python寫乙個helloworld的小程式,直接在hello.py輸入
print 'hello world'
2、還可以把hello.py寫成乙個可執行的指令碼,如下:
#!/usr/bin/env python
'hello world
'
還需要給上面的**賦予可執行的許可權,如下:
#chmod 755 hello.py
命令列執行:
#./hello.py
【第二課】基礎資料型別
1、變數不需要定義
a=10print a
print type(a)
輸出:10
type():內建函式,查詢變數的型別。
2、**變數名
如果想讓a儲存不同的值,不用刪除a,直接給它賦值即可。
a=1.5print a,type(a)
輸出1.5,
print後可以跟多個輸出,以逗號隔開即可。
3、基礎資料型別
整型、浮點型、布林型(true/false)、字串型(單雙引號都可用)
python學習筆記 第1天
首先就是裝飾器的裝飾和呼叫,直接上 1.首先裝飾器的裝飾順序是從下往上進行裝飾 2.呼叫的時候要從上往下進行呼叫 舉例 def w1 func print 正在裝飾1 def inner print 正在呼叫1 func return inner def w2 func print 正在裝飾2 de...
Python基礎學習(第3天)
第6課 迴圈 1 for 元素 in 序列 statement python的新函式range 新建乙個數列,都是整數,從0開始,下乙個元素比上乙個元素大1,一直到數列的上限 不包括上限 ps range 在3.2中用法有變化 1 for a in range 5 2 printa 3 輸出 4 1...
Python基礎學習(第4天)
python高階 第1課 詞典 dictionary 1 詞典可以儲存多個元素,儲存多個元素的物件稱為容器 container 1 開啟乙個檔案,用物件來代表這個檔案 f open 檔名,模式 模式 r 讀取,w 寫入 2 檔案物件常用的方法 content f.read n 讀取n byte的資料...