Time of Update: 2015-07-20
標籤:#歸併排序def mergeSort(a,L,R) : if(L>=R) : return mid=((L+R)>>1) mergeSort(a,L,mid) merg
Time of Update: 2015-07-17
標籤:BeautifulSoup 一個分析、處理DOM樹的類庫。 採集所有img標籤的title屬性的內容# -*- coding: utf-8 -*- from urllib.request import urlopenfrom urllib.error import HTTPErrorfrom bs4 import BeautifulSoupurl =
Time of Update: 2015-07-16
標籤:python 文檔 Python 標準庫 BaseHTTPServer 中文翻譯。 注意: BaseHTTPServer模組在Python3中已被合并到http.server,當轉換你的資源為 Python3 時 2to3 工具將自動適配匯入。源碼:Lib/BaseHTTPServer.py此模組定義了兩個類用於實現HTTP伺服器(Web servers)。通常,此模組不被直接使用,但是它用來作為基類建立功能性的Web
Time of Update: 2015-07-17
標籤:一、起因今天在做角色控制中,有一個地方用到rstrip,判斷使用者請求的url是否與資料庫對應可用許可權中url相符。if request.path == x.url or request.path.rstrip(‘/‘) == x.url:
Time of Update: 2015-07-16
標籤:這是在Python學習小組上介紹的內容,現學現賣、多練習是好的學習方式。第一步:最簡單的函數,準備附加額外功能?12345678# -*- coding:gbk -*-‘‘‘樣本1: 最簡單的函數,表示調用了兩次‘‘‘ defmyfunc(): print("myfunc() called.") myfunc()myfunc() 第二步:使用裝飾函數在函數執行前和執
Time of Update: 2015-07-16
標籤:python 圖形編程 from Tkinter import *root=Tk()root.title("my test")root.mainloop() #主迴圈以上是建立一個空白的表單====================================== button1=Button(root,text="button1")button2=Button(root,text="button2")but
Time of Update: 2015-07-16
標籤:python system import #!/usr/bin/env pythonimport subprocesstry:import simplejson as jsonexcept:import jsonmemory_status = {} p = subprocess.P
Time of Update: 2015-07-16
標籤: 大家好,還記得我當時學習python的時候,我一直努力地尋找關於python的部落格,但我發現它們的數量很少。這也是我建立這個部落格的原因,向大家分享我自己學到的新知識。今天我向大家推薦10個值得我們關注的python部落格,這些部落格的博主都會週期性更新而且他們的文章都很不錯。下面是部落格列表: 1.首先第一個肯定是毋庸置疑的Planet
Time of Update: 2015-07-16
標籤:先定義一個帶預設參數的函數:def add_end(L=[]): L.append(‘END‘) return
Time of Update: 2015-07-16
標籤:Linux下配置Apache+Mod_Wsgi+Django環境(ybw 2011-09-23)一.安裝環境作業系統:CentOS release 5.5核心版本:Linux Svn-168-1-11 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x8
Time of Update: 2015-07-14
標籤:http://blog.csdn.net/rumswell/article/details/9818001# -*- coding: utf-8 -*-#~ #----------------------------------------------------------------------#~ module:wlab#~ Filename:wgetfilelist.py#~ Function :#~ def IsSubString(SubStrList,Str)#~
Time of Update: 2015-07-14
標籤:摘自:http://www.jb51.net/article/60641.htm #!/usr/bin/env python import globimport osos.chdir(“./”)for file in glob.glob(“*.py”):print file print “#######Another One##########” for file in
Time of Update: 2015-07-13
標籤:__author__ = ‘Administrator‘#/usr/env/bin python‘‘‘ this is document‘‘‘class Event(object): ‘‘‘ 事件初始化的一個方式 ‘‘‘ &nb
Time of Update: 2015-07-12
標籤:因為工作的關係,我寫過許多個抓取網站資訊的程式。最簡單的,只要用Python的urllib2.urlopen()函數就可以了;然後,有個網站喜歡封人,所以,得找一批代理,輪流抓它的資訊;有的網站不允許程式抓取,所以,就得加入一些頭資訊;有的網站需要登入,這時就要用到Cookies;最後,為了提高效率,最好是使用多線程。(PS,有個地方要注意,urlopen這個函數,設定了一個全域對象opener,所以如果你使用了多個線程,
Time of Update: 2015-07-12
標籤:影像處理 python opencv 形態學一般是使用二值映像,進行邊界提取,骨架提取,孔洞填充,角點提取,映像重建等等。常用的形態學操作時腐蝕與膨脹,在他們的基礎上演變出一些變體,包括開運算、閉運算、梯度等等。形態學一般是對二值映像進行的操作。下面貼幾個比較好的介紹映像形態學方面的部落格 影像處理基本演算法-形態學
Time of Update: 2015-07-12
標籤:python與之前接觸過的語言不同,python有針對迴圈的else,表示如果迴圈結束都沒有執行裡面的break語句就進入到這個else,所以這個else在格式上是與for對齊的。例:import mathfor i in range(85, 99): root = math.sqrt(i) if root == int(root): breakelse: print 'no int root'
Time of Update: 2015-07-11
標籤:from <python cookbook>
Time of Update: 2015-07-11
標籤:在Python中,可以通過and,or和not進行邏輯運算,下面就來看看and和or的簡單介紹。邏輯與-and對於包含and運算的運算式,Python解譯器將從左至右掃描,返回第一個為假的運算式值,無假值則返回最後一個運算式值。下面看一個使用and的例子:# if all the expressions are true, return the last expressionprint {"name": "Will"} and "hello" and 1# return the
Time of Update: 2015-07-10
標籤: 異常資訊的擷取對於程式的調試非常重要,可以有助於快速定位有錯誤程式語句的位置。下面介紹幾種python中擷取異常資訊的方法,這裡擷取異常(Exception)資訊採用try...except...程式結構。如下所示try: ...except Exception, e: ... 1、str(e)返回字串類型,只給出異常資訊,不包括異常資訊的類型,如1/0的異常資訊‘integer division or modulo by zero‘2、repr(e)給出較全的異常資訊,
Time of Update: 2015-07-17
Python背景色與文法高亮主題配置使用python idle的人恐怕都無法忍受預設的白色背景,及其文法高亮主題。大家更傾向於使用黑色背景。下面介紹Obsidian, Desert, 和Tango三種主題配置在 使用者目錄 的.idlerc 目錄下建立名為 config-highlight.cfg 檔案,並加入如下內容[tango]definition-foreground = #fce94ferror-foreground = #fa8072string-background = #2e343