Time of Update: 2017-01-20
標籤:空格 開啟 input cd命令 串連 學習 功能 區別 c語言 首先是下載python 官網下載即可
Time of Update: 2017-01-19
標籤:html 文字 import 作用 ber 其他 tle com from 目的:顯示糗百多頁文字內容,一次看個夠,節約時間。工具:python
Time of Update: 2017-01-19
標籤:requests python requests 第三方requests python requests拓展 介紹python的requests模組是python一個強大的第三方HTTP請求庫,簡單易用安裝: pip install requestsimport
Time of Update: 2017-01-19
標籤:指令碼 sel pcl ssh /tmp sftp fga elf upload Bastion Host前戲開發Bastion Host之前,先來學習Python的paramiko模組,
Time of Update: 2017-01-19
標籤:之間 計算 str 基本操作 mis 元素 最小值 bsp logs 元組的基本操作:1.建立一個元組:tuple=(1,26);tuple1=("15","sy");建立一個空元組:tu
Time of Update: 2017-01-19
標籤:python vscode 無意看到老男孩的博文:合格linux營運人員必會的30道shell編程面試題及講解http://oldboy.blog.51cto.com/2561410/1632876嘗試著用剛開始學的python解答一些,權當練手了!如有錯誤,還請批評!# 企業面試題10:請用至少兩種方法實現!# bash for迴圈列印下面這句話中字母數不大於6的單詞(崑崙萬維面試題)。# I am oldboy
Time of Update: 2017-01-19
標籤:ret app -- imp logs gen div cookie secure 基於python2.7get與post:url =
Time of Update: 2017-01-19
標籤:內聯 語句 round 分配 包含 bsp strip list sort nal 使用選擇性參數定義函數選擇性參數可以通過分配(用定義=)的預設值的參數名:def
Time of Update: 2017-01-19
字典 :一個關聯陣列或散列表 ,可通過關鍵字索引的對象。字典的用途:定義一個可包含多個命名欄位的對象,也可以用作快速尋找無序資料的容器字典是python中最完善的資料類型 在程式中最常用於儲存和處理資料如何建立:1,在{}中放入值即可建立一個空字典;2,使用方法 dict() 建立一個空的字典data = { "name" : "神行太保戴宗", 'title' :'天速星', '
Time of Update: 2017-01-19
常用的迴圈結構是用於迭代多個項的for語句,迴圈是python最重要的功能之一,最常見的迭代只是迴圈一個序列(字串,列表,或者元組)的所有成員1,迭代列表:for n in [1,2,3,4,5,6,7,8,9]: print("number:%d value: %d" %(n,2*n))輸出結果:number:1 value: 2number:2 value: 4number:3 value: 6number:4 value: 8number:5 value:
Time of Update: 2017-01-19
產生器yield:使用yield語句 可以讓函數產生一個結果序列而不僅僅是一個值def countdow(n): print("Start!"); while n>0: yield n; n -= 1; c = countdow(5); print(c.__next__())
Time of Update: 2017-01-19
協程:將函數編寫為一個能處理輸入參數的任務使用yield語句並以運算式yield的形式建立協程#匹配器案例:def print_info(data): print('Looking for',data); while True: line = (yield) if data in line: print(line);上面這個函數 就是一個協程程式 要使用這個函數 首先需用調用它 並且 向前執行到第一條yield語句info
Time of Update: 2017-01-19
對象:程式中使用的所有值都是對象,對象由內部屬性和方法組成 這些方法會執行與資料相關的各種操作,前面巨集指令清單類型資料時 我們已經用過了方法:data = [37,34]; data.insert(1,25); data.append(23) print(data);輸出結果:37,25,34,23dir()函數 可以列出對象上可用的方法 是進行互動式體驗的工具dir(data)輸出結果: ['__add__', '__class__', '__
Time of Update: 2017-01-19
模組:隨著程式變的越來越大 為了便於維護 需要把它分為多個檔案 為此python允許把定義放入一個檔案 然後在其他指令碼中將其作為模組匯入 建立模組: 將相關的語句和定義放入與模組同名的檔案中 #file:module.py def numValue(a,b): q = a/b r = a-q*b return (q,r);要在其他的程式中使用該模組 則可以使用import語句:import module; a,b = module.numValue(64,8)
Time of Update: 2017-01-19
程式中每條語句都以分行符號結束 可以使用續行符(\)反斜線將長語句分為幾行wather_is_hot = 1; watherer = 0; if(wather_is_hot ==1) and \ (watherer==0): print("杯子裡的水是熱的");有兩種列外的情況下 一個語句不適用反斜線也可以跨行 1,單一語句可以跨行 如:含有 小括弧 中括弧 花括弧時可以多行書寫 例:dict = { 'title
Time of Update: 2017-01-19
組合模式我們把Composite模式看成一個複雜的屬性結構,其實基本有三種角色:樹榦(定義一些操作樹葉leaf的操作),樹枝(樹榦上有很多樹枝)和樹葉(樹榦想要具體操作的對象) ,Composite模式幫我們實現:即它們在充當對象的時候,還是其他對象的容易,從而提供一致性python的例子class Trunk(object): '''樹榦''' def __str__(self): pass def subtree(self):
Time of Update: 2017-01-19
Python內建函數——repr & strrepr & strrepr(object) &
Time of Update: 2017-01-19
Python內建函數——filterfilterfilterfilter(function,
Time of Update: 2017-01-19
Python內建函數——compilecompilecompile(source, filename, mode[, flags[,
Time of Update: 2017-01-19
Python內建函數——hasattr&setattr&getattr&delattrhasattr & setattr & getattr & delattrhasattr(object,name):用於判斷一個對象裡中是否存在name這一特性.setattr(object, name, value):該函數給對象中的屬性賦值,該屬性若不存在,則會在對象裡建立新的屬性delattr(object,