Time of Update: 2015-07-31
標籤:python筆記,寫在前面:python區分大小寫1、科學計數法,把10用e代替,1.23x10·9就是 1.23e9 或者 0.00012就是1.2e-4
Time of Update: 2015-07-31
標籤:Test-Driven Development PrinciplesTDD consists of writing test cases that cover a desired feature, then writing the feature itself. In other words, the usage examples are written before the code even exists.For example, a developer who is asked
Time of Update: 2015-07-30
標籤: 1.變數可以指向函數,也可以使用變數和參數的形式完成函數調用。 2.那麼函數名是什麼呢?函數名其實就是指向函數的變數!對於abs()這個函數,完全可以把函數名abs看成變數,它指向一個可以計算絕對值的函數! 3.可以對__builtin__模組中進行修改,則abs變數指向也會改變。 4.高階函數就是將一個函數作為另一個函數的參數。 5.map()函數解釋:接收兩個參數,一個是函數,一個是Iterable,map將傳入的函數依次作用到序列的
Time of Update: 2015-07-31
標籤: @Python新式類和經典類的區別
Time of Update: 2015-07-31
標籤:@[深入Python]__new__和__init__12345678class A(object): def __init__(self): print "init" def __new__(cls,*args, **kwargs):
Time of Update: 2015-07-30
標籤:1.
Time of Update: 2015-07-30
標籤:@Python的getattr(),setattr(),delattr(),hasattr()先轉一篇博文,參考。最後再給出一個例子getattr()函數是Python自省的核心函數,具體使用大體如下:擷取對象引用getattrGetattr用於返回一個對象屬性,或者方法class A: def __init__(self):
Time of Update: 2015-07-30
標籤:一、對象和類型 1、五種基礎資料型別 (Elementary Data Type): 1、字串(String),簡記為str,使用‘‘或""括起來的一系列字串 2、整數(integer),簡記為int,十進位、八進位、十六進位 3、浮點數(float),例如1.48, 21.0, 21., .21, 21.E2 4、布爾數(boolean),簡記為bool,True,False 5、複數(complex),1+1j 2、
Time of Update: 2015-07-30
標籤: 正式開始第1關,這一關的URL的特殊部分是map。
Time of Update: 2015-07-30
標籤:python 倒序輸入 By Dolphin , 20150730Title : 編寫一個程式,擷取使用者輸入的一條資訊,然後將其倒序輸出。Code:# Reverse Word# By Dolphin,20150730#word = input("Please Enter a word :")#&
Time of Update: 2015-07-30
標籤:python linux 爬蟲 批量下載 使用Python
Time of Update: 2015-07-30
標籤:python tornado web-server 1. What is TornadoTornado是一個輕量級但高效能的Python web架構,與另一個流行的Python web架構Django相比,tornado不提供操作資料庫的ORM介面及嚴格的MVC開發模式,但可以提供基本的web server功能,故它是輕量級的;它藉助non-blocking and
Time of Update: 2015-07-30
標籤:python 爬蟲 url #encoding:UTF-8import urllibimport urllib.request# data是一個字典,然後通過urllib.parse.urlencode()將data轉換為'wd = 904727147'的字串#最後和url合并為full_url#
Time of Update: 2015-07-30
標籤:讀書筆記 python 下面開始是進階部分了。四、類 1. 類 在Python2.2之前使用的是舊式類,2.2版本之後使用的是新式類,但是在Python3之後就不存在這個問題了。下面談論的問題是關於新式類的。 關於新式類的定義有兩種方式。
Time of Update: 2015-07-30
標籤:print和import的更多資訊使用逗號輸出>>> print ‘age:‘, 42age: 42>>> 1,2,3(1, 2, 3)>>> print 1,2,31 2 3>>> print (1,2,3)(1, 2, 3)>>> name=‘Gumby‘>>> salutation=‘Mr.‘>>> greeting=‘Hello,‘>>>
Time of Update: 2015-07-30
標籤:項目背景:生產環境中需要部署幾百台我寫的一個採集監控程式,但近期需求改動較多,需要每隔一段時間就更新一個版本,人工更新太費事,所以我又寫了一個跨平台的基於Python的自動更新程式,通過自訂更新策略部署新的版本,由於我的採集監控程式是通過Python指令碼寫的(跨平台,部署在WIN2K8,HPUX,AIX),在Windows環境中,XXX.py作為Python.exe的命令列參數啟動,所以,通過:taskkill /F /IM XXX.py是行不通的(如果尾碼是EXE,則
Time of Update: 2015-07-30
標籤:python內部提供了很多內建函數。下面讓我們從a-z開始學習python的內建函數1.1id(object)返回對象的id(身份),返回的這個是一個整數(integer)是唯一的,在這個對象的整個生命週期內這個id都是唯一的就是說兩個不同是存在的兩個數是可以有相同的id的。這是對象在記憶體中的地址。一個執行個體:a =
Time of Update: 2015-07-30
標籤:#encoding:UTF-8import urllibimport urllib.request# data是一個字典,然後通過urllib.parse.urlencode()將data轉換為‘wd = 904727147‘的字串#最後和url合并為full_url# urllib.request是一個庫,隸屬urllib,urllib是一個收集了很多處理url的包,開放網址的可擴充庫。# urllib.request
Time of Update: 2015-07-30
標籤:linspace arange python python中linspace()和arange()的區別今天無意間看到linspace(0,4,5)可以產生一個array([0,1,2,3,4])的數組,不知道裡面的參數是什麼,於是就有了這篇博文。linspace(
Time of Update: 2015-07-30
標籤:其實很簡單,用python -m py_compile file.pypython -m py_compile /root/src/{file1,file2}.py編譯成pyc檔案。也可以寫份指令碼來做這事:Code:import py_compile py_compile.compile(‘path‘) //path是包括.py檔案名稱的路徑用python -O -m py_compile file.py編譯成pyo檔案。1.其中的 -m 相當於指令碼中的import,這裡的-