Time of Update: 2018-12-04
文章目錄 urllib2 Requests這是urllib2的方法:Requests ref: http://dancallahan.info/journal/python-requests/Title: 有用的python模組在HTTP相關處理中使用python是不必要的麻煩,這包括urllib2模組以巨大的複雜性代價擷取綜合性的功能。相比於urllib2,Kenneth
Time of Update: 2018-12-04
總的來說是一個只支援一個聊天室的伺服器端 用戶端使用telnet書籍:Python資料匯總Python教程 這裡是第二十四章的源碼,練習研究之用#coding:utf8 #python2.7 chatSer2.py#稍微複雜一點的聊天室伺服器'''用python啟動服務 telnet串連之後就可以變成簡單的聊天伺服器第一次登陸:login name 登出: logout說話: say 查看誰登陸過伺服器:who 查看同一個房間的人 : look 簡單例子:telnet localhost 50
Time of Update: 2018-12-04
收集了一些資料,基本來自網路下載,如果有新的,後續添加Python核心編程 Python進階編程Python資料結構與演算法英文Python灰帽子中文Python精要參考中文ThinkPython Python linux unix系統管理指南中文精通RegexPython cookbook 中文以上均來自網路下載,著作權問題深感憂慮。。Python基礎教程 中文第二版
Time of Update: 2018-12-04
ref= http://www.slideshare.net/wilhelmshen/py-art1. Python 編程藝術享受高效無誤且充滿樂趣的編程2. def hello(): print hello world!3. 什麼樣的函數返回 None?4. 沒有訊息就是最好的訊息5. 對許多有經驗的程式員來說True / 1 並不是執行成功的意思6. None 是最好的沉默 雖然 0 也不錯,然而在 Python 中預設的傳回值是 None7. 函數不能既返回結果 又返回錯誤8.
Time of Update: 2018-12-04
對於python中的序列類型的資料結構list的操作,最多的可能就是增刪操作了。In [37]: a = [1,2]In [38]: dir(a)['append','count','extend','index','insert','pop','remove','reverse','sort']這是他的內建方法,基本上都是經常用的比如說添加一個元素從末尾添加:In [39]: a.append([3,4])In [40]: aOut[40]: [1, 2, [3, 4]]從頭添加:In [43
Time of Update: 2018-12-04
錯誤的log是(env)lzz@ubuntu:~/Virtualenv/blog1_django_1.4/eshop$ easy_install pilSearching for pilReading http://pypi.python.org/simple/pil/Reading http://www.pythonware.com/products/pilReading http://effbot.org/zone/pil-changes-115.htmReading
Time of Update: 2018-12-04
os win7 python2.7#coding=utf8import urllib2,re,os import threadingimport time,datetimedef get_proxy_addr(urls,ports): proxylist = [] p = re.compile('''<tr><td>(.+?)<SCRIPT
Time of Update: 2018-12-04
轉載自ref: http://shell909090.com/blog/2012/11/python%e5%85%a5%e9%97%a8%e6%8c%87%e5%bc%95/python入門指引發表於 2012 年 11 月 19 日前言其實我也不知道python怎麼入門,由我來寫這個真的不是很合適。我學python是直接找了dive into
Time of Update: 2018-12-04
virtualenv 是一個建立隔離的Python環境的工具。virtualenv要解決的根本問題是庫的版本和依賴,以及許可權問題。假設你有一個程式,需要LibFoo的版本1,而另一個程式需要版本2,如何同時使用兩個應用程式呢?如果將所有的庫都安裝在 /usr/lib/python2.7/site-packages(或者你的系統的標準包安裝路徑),非常容易出現將不該升級的庫升級的問題。也就是說他會創造一個單獨的環境來滿足當前項目的需求。os:win7安裝: easy_install
Time of Update: 2018-12-04
python2.73python函數中有個叫做閉包的用法,其實還有一種類操作中類似閉包的效果>>> class A:... pass...>>> a = A>>> a<class __main__.A at 0x02BEC500>>>> b = A()>>> b<__main__.A instance at 0x02C1BBE8>>>> type(a)
Time of Update: 2018-12-04
解決方案就是增添一個參數看下代碼對比#coding:utf8#python2.7 winxpimport urllibimport sys import json#url = r'http://www.weather.com.cn/data/sk/101221201.html'url = r'http://www.weather.com.cn/data/cityinfo/101221201.html'res = urllib.urlopen(url) #返回的是個json串jinfo =
Time of Update: 2018-12-04
正則對於文本文文書處理很好用,以前總是覺得很難似的,認真的學習一下發現入門還是很簡單的。首先說的是元字元:[] :-常用來制定一個字元集,只能匹配一個字元 [abc] 匹配a,b或者 c -其他的元字元在[]中不起作用 - '^'表示補集,'-'表示範圍 import rer='a[abc]c're.findall(r,'abc aac adc ')['abc', 'aac']r=r'a[bcd$]'re.findall(r,'ad')['ad']re.findall(r,'ab')[
Time of Update: 2018-12-04
使用threading的繼承Treading的方法#coding:utf8'''def isprime(m): #質數是指只能被1和它本身整除的數 for i in range(2, m/2+1): if m % i == 0: return False return Trueif __name__ == '__main__': print filter(isprime,
Time of Update: 2018-12-04
文章目錄 需求:設計:編碼:測試:總結: 第一個小應用: 案頭天氣需求:背景:簡單的一個桌面視窗,顯示某地區的天氣情況,每小時一次來源,使用者:自己價值:編程練習 設計:使用tkinter做出一個小視窗,後天通過中央氣象的json介面獲得天氣情況,手動更新也可以首先解決擷取json並解析,然後是視窗顯示。編碼:#coding:utf8#python2.73 winxp '''天氣外掛程式:
Time of Update: 2018-12-04
what is static method?python2.73 docStatic method objects Static method objects provide a way of defeating the transformation of function objects to method objects described above. A static method object is a wrapper around any other object, usually
Time of Update: 2018-12-04
Scrapy: os:win7 python:2.7 首先是安裝easy_install scrapy是的 很容易就安裝好了,難的是那麼多的依賴包 http://doc.scrapy.org/en/0.16/intro/install.html 這裡有win下的安裝指導 如果實在編譯不過,或者是要安裝太多win的東西,就去 http://www.lfd.uci.edu/~gohlke/pythonlibs/ 下載一個編譯好的庫安裝吧 第一步:建立一個項目
Time of Update: 2018-12-04
總得思路很簡單:擷取一個cookie裝載好自己的request發送請求#coding:utf8 '''類比登陸人人 根據網上的資料和firefox做了下 首先自己去探查了下頁面元素:<input id="email" class="input-text" type="text" value="" tabindex="1" name="email" style="color: rgb(136, 136, 136);"></input<input id="password"
Time of Update: 2018-12-04
ref:http://net.tutsplus.com/tutorials/the-best-way-to-learn-python/ post by Mark DunnePython is more popular than ever, and is being used everywhere from back-end web servers, to front-end game development, and everything in between. Python is a
Time of Update: 2018-12-04
1.兩個字串放在一起會自動合并 "Let's say " '"Hello, world!"' --->'Let/'s say "Hello, world!"' 但是兩個字串變數放在一起中間要加“+”號才會合并 2.str與repr str會將變數轉化成某種使用者能夠理解的String方式,如 print str(10000L) --->10000 #str(object) -- Converts a value to a string repr會將變數轉化為Python的合法變數
Time of Update: 2018-12-04
1.下標從0開始,-1代表最後一個元素,-2為倒數第二個。 2.因為順序化操作是內建的,所以形如 'Hello'[1] fourth = raw_input('Year: ')[3] 均為合法輸入 3.可以用*來重複List的值 如action = 3 * ['go'] --->(['go'] * 3也一樣) ['go', 'go', 'go'] 而action = 3 * 'go' --->('go' * 3也一樣) 'gogogo' 4.片段的範圍只含上界,不含下界。In