原创 Using Lists as Queues in Python----在Python中把鏈表當作隊列使用

    It is also possible to use a list as a queue, where the first element added is the first element retrieved (``first

原创 More on Lists in Python----深入Python列表

    The list data type has some more methods. Here are all of the methods of list objects:     鏈表類型有很多方法,這裏是鏈表類型的所有方法:

原创 Python核心編程學習筆記(二)

        7、賦值         Python不支持C語言中的自增1和自減1運算符,這是因爲+和-也是單目運算符,Python會將--n解釋爲-(-n)從而得到n,同樣++n的結果也是n。           8、數字      

原创 Python核心編程學習筆記(四)

        16、文件和內建函數open()、file()         打開文件:handle = open(file_name, access_mode = 'r')         access_mode中,'r'表示讀取,'

原创 Using Lists as Stacks in Python----在Python中把鏈表當作堆棧使用

    The list methods make it very easy to use a list as a stack, where the last element added is the first element retr

原创 Python核心編程學習筆記(七)

        26、Python對象,所有的Python對象都擁有三個特徵:身份、類型 和 值。         身份:可以使用內建函數id()來得到,可以被認爲是該對象的內存;         類型:可以使用內建函數type()查看對

原创 Python核心編程學習筆記(五)——第二章習題

        第二章習題         2-6 條件判斷         判斷用戶輸入的是正數,負數 還是 0。 str = raw_input('Enter a number:') num = int(str) if num

原创 Python核心編程學習筆記(八)——第五章習題

第五章習題         5-2 運算符         (a) 寫一個函數,計算並返回兩個數的乘積         (b) 寫一段代碼調用這個函數,並顯示它的結果      #!encoding:utf-8 def mul(fa

原创 Python核心編程學習筆記(三)

        12、if語句      if expression1: if-suite elif expression2: elif_suite else: else_suite         13、whil

原创 Python核心編程學習筆記(六)

        22、語句和語法         (1) 註釋(#),井號之後的內容爲Python的註釋         (2) 繼續(\),一行過長的語句可以使用反斜槓(\)分解成幾行,有兩種例外情況一個語句不使用反斜線也可以跨行。在使

原创 Python中常見的文件對象內建函數

文件對象內建方法列表 文件對象的方法 操作 file.close() 關閉文件 file.fileno() 返回文件的描述符(file descriptor,FD,整數值) file.flush() 刷新文件的內部緩衝區 file.isa

原创 Python正則表達式

        1、正則表達式(RE)         是一些由字符和特殊符號組成的字符串,它們描述了這些字符和字符的某種重複方式,因此能按某種模式匹配一個有相似特徵的字符串的集合,因此能按某模式匹配一系列有相似特徵的字符串。      

原创 Sublime text 設置Tab爲4個空格

Sublime text 2: Preferences,Settings-Defalut: 【將Tab鍵自動替換爲4個空格】 // The number of spaces a tab is considered equal to

原创 Python核心編程學習筆記(十)——第七章習題

        7-1 字典方法。         哪個字典方法可以用來把兩個字典合併到一起?         update() 方法可以實現。 >>> myDict = {'name': 'earth', 'port': '8080'}

原创 socket()函數介紹

socket()函數介紹 socket函數介紹 函數原型 domain type protocol errno 示例 函數原型 socket()函數的原型如下,這個函數建立一個協議族爲domain、協議類型爲type、協議編