對web伺服器做健全狀態檢查,一般我們都是用curl庫(不管是php,perl的還是shell的),大致的方法一致:複製代碼 代碼如下:curl -I -s www.qq.com |head -1|awk '{ health = $2=="200"?"server is ok":"server is bad"}END{print health}'server is
平時我們寫個指令碼,要放到後台執行去,我們怎麼做呢?複製代碼 代碼如下:nohup python example.py 2>&1 /dev/null &用tumx或者screen? 但是用著可能都不爽,今天就看看python裡面的一個進程管理工具supervisor:官方說:Supervisor: A Process Control
對list的操作合并list《有容乃大的list(1)》中,對list的操作提到了list.append(x),也就是將某個元素x 追加到已知的一個list後邊。除了將元素追加到list中,還能夠將兩個list合并,或者說將一個list追加到另外一個list中。按照前文的慣例,還是首先看官方文檔中的描述:list.extend(L)Extend the list by appending all the items in the given list; equivalent to
看到類似__slots__這種形如__xxx__的變數或者函數名就要注意,這些在Python中是有特殊用途的。__slots__我們已經知道怎麼用了,__len__()方法我們也知道是為了能讓class作用於len()函數。除此之外,Python的class中還有許多這樣有特殊用途的函數,可以協助我們定製類。__str__我們先定義一個Student類,列印一個執行個體:複製代碼 代碼如下:>>> class
本文執行個體講述了python網路編程,分享給大家供大家參考。具體方法如下:服務端代碼如下:from SocketServer import(TCPServer as TCP, StreamRequestHandler as SRH) from time import ctime HOST = '' PORT = 21567 ADDR = (HOST, PORT) class MyRequestHandle(SRH): def handle(self):
本文執行個體講述了python的re模組應用。是非常重要的應用技巧。分享給大家供大家參考。具體方法如下:import re # match_object = re.match('foo','foo') if match_object is not None: print type(match_object) print match_object.group() # match_object = re.match('foo','fooabv') if match_object is