Time of Update: 2016-06-16
1,首先是視頻資料[網路攝影機映像]的採集,通常可以使用vfw在vc或者vb下實現,這個庫我用的不好,所以一直不怎麼會用.現在我們用到的是python的videocapture庫,這個庫用起來很簡單,如下:複製代碼 代碼如下:from VideoCapture import Devicecam = Device()cam.setResolution(320,240) #設定顯示解析度cam.saveSnapshot('demo.jpg')
Time of Update: 2016-06-16
複製代碼 代碼如下:import osdef load() : filename = os.getcwd() + r'\fromto.txt' if os.path.isfile(filename) : f = open(filename) try : lines = f.readlines() finally : f.close() return lines
Time of Update: 2016-06-16
win7以上需要使用管理員權限操作。複製代碼 代碼如下:# -*- coding: utf-8 -*-import osimport globimport shutildef format_file_list(files): all_files_str = "" for i in range(len(files)): all_files_str += str(i)+":"+files[i]+"\n" return all_
Time of Update: 2016-06-16
首先是,從網路攝影機截取一幅映像:複製代碼 代碼如下:while 1: #測試網路攝影機的存在 try: cam = Device() except: print "no webcam found!" continue break然後是把映像上傳到ftp伺服器:複製代碼 代碼如下:remote = ftplib.FTP('127.0.0.1') #登陸伺服器remote.login()file =
Time of Update: 2016-06-16
主要功能在copyFiles()函數裡實現,如下:複製代碼 代碼如下:def copyFiles(src, dst): srcFiles = os.listdir(src) dstFiles = dict(map(lambda x:[x, ''], os.listdir(dst))) filesCopiedNum = 0 # 對源檔案夾中的每個檔案若不存在於目的檔案夾則複製 for file in srcFiles: src_path =
Time of Update: 2016-06-16
複製代碼 代碼如下:# -*- coding: utf8 -*-'''Created on 2013-12-19@author: good-temper'''import urllib2import urllibimport cookielibimport reimport bs4URL_BAIDU_INDEX =
Time of Update: 2016-06-16
1、主函數(WeiboMain.py):複製代碼 代碼如下:import urllib2import cookielibimport WeiboEncodeimport WeiboSearchif __name__ == '__main__': weiboLogin = WeiboLogin('×××@gmail.com', '××××')#郵箱(帳號)、密碼 if weiboLogin.Login() == True: print
Time of Update: 2016-06-16
在python中,一般可以使用pickle類來進行python對象的序列化,而cPickle提供了一個更快速簡單的介面,如python文檔所說的:“cPickle -- A faster pickle”。cPickle可以對任意一種類型的python對象進行序列化操作,比如list,dict,甚至是一個類的對象等。而所謂的序列化,我的粗淺的理解就是為了能夠完整的儲存並能夠完全可逆的恢複。在cPickle中,主要有四個函數可以做這一工作,下面使用例子來介紹。1, dump:
Time of Update: 2016-06-16
複製代碼 代碼如下:import socketimport re'''廣東省公安廳出入境政務服務網護照,通行證辦理進度查詢。分析網址格式為 http://www.gdcrj.com/wsyw/tcustomer/tcustomer.do?&method=find&applyid=社會安全號碼碼構造socket請求網頁html,利用正則匹配出查詢結果'''def gethtmlbyidentityid(identityid): s = socket.socket(socket.AF_INET,
Time of Update: 2016-06-16
複製代碼 代碼如下:# _*_ coding: utf-8 _*_#---------------------------------------# 程式:把本地檔案上傳到七牛雲端服務器# 版本:0.1# 作者:liu jia# 日期:2014-01-07# 語言:Python 2.7#---------------------------------------import qiniu.confimport sysimport os#登入後從#https://portal.
Time of Update: 2016-06-16
複製代碼 代碼如下:def loginTom(username, password): url1 = ''' http://login.mail.tom.com/cgi/login ''' values = { 'type' : '0', 'user' : '%s' % username, 'in_username' : '%s@tom.com' % username, 'pass' : '%s' % password, 'style' : '21', 'verifycookie'
Time of Update: 2016-06-16
如果你對在Python產生隨機數與random模組中最常用的幾個函數的關係與不懂之處,下面的文章就是對Python產生隨機數與random模組中最常用的幾個函數的關係,希望你會有所收穫,以下就是這篇文章的介紹。random.random()用於產生用於產生一個指定範圍內的隨機符點數,兩個參數其中一個是上限,一個是下限。如果a > b,則產生隨機數n: a print random.uniform(10, 20) print random.uniform(20, 10) #---- #18.7
Time of Update: 2016-06-16
代碼基於Python3.3.3,PyQt5.1.1複製代碼 代碼如下:# -*- coding: utf-8 -*-# Python 3.3.3# PyQt 5.1.1import sys,time,re,urllib.parse,urllib.request,http.cookiejar,jsonfrom PyQt5.QtCore import *from PyQt5.QtGui import *from PyQt5.QtWidgets import
Time of Update: 2016-06-16
我有的時候寫程式要用到目前時間,我就想用python去取當前的時間,雖然不是很難,但是老是忘記,用一次丟一次,為了能夠更好的記住,我今天特意寫下擷取目前時間的方法,如果你覺的對你有用的話,可以收藏下。取得時間相關的資訊的話,要用到python time模組,python time模組裡面有很多非常好用的功能,你可以去官方文檔瞭解下,要取的目前時間的話,要取得目前時間的時間戳記,時間戳記好像是1970年到現在時間相隔的時間。你可以試下下面的方式來取得目前時間的時間戳記:import
Time of Update: 2016-06-16
複製代碼 代碼如下:import urllib.parse,os.path,time,sys,re,urllib.requestfrom http.client import HTTPSConnectionfrom PyQt5.QtCore import *from PyQt5.QtGui import *from PyQt5.QtWidgets import *from PyQt5.QtWebKitWidgets import *from PyQt5.QtNetwork import
Time of Update: 2016-06-16
crtrl.py監控Apache伺服器處理序的Python 指令碼複製代碼 代碼如下:!/usr/bin/env Python import os, sys, time while True: time.sleep(4) try: ret = os.popen('ps -C apache -o pid,cmd').readlines() if len(ret) print "apache 進程異常退出, 4 秒後重新啟動" time.sleep(3) os.system("service
Time of Update: 2016-06-16
複製代碼 代碼如下:import urllib.parse,os.path,time,sysfrom http.client import HTTPSConnectionfrom PyQt5.QtCore import *from PyQt5.QtGui import *from PyQt5.QtWidgets import *#pathospath=sys.path[0]if len(ospath)!=3: ospath+='\\'ospath=ospath.replace('\\','
Time of Update: 2016-06-16
net.py 擷取網路介面的輸入和輸出複製代碼 代碼如下:#!/usr/bin/env Pythonimport timeimport sysif len(sys.argv) > 1: INTERFACE = sys.argv[1]else: INTERFACE = 'eth0'STATS = []print 'Interface:',INTERFACEdef rx(): ifstat = open('/proc/net/dev').readlines() for interface in
Time of Update: 2016-06-16
python發送icmp echo requesy請求複製代碼 代碼如下:import socketimport structdef checksum(source_string): sum = 0 countTo = (len(source_string)/2)*2 count = 0 while count thisVal = ord(source_string[count + 1])*256 + ord(source_string[count])
Time of Update: 2016-06-16
複製代碼 代碼如下:#!/usr/bin/env Pythonfrom __future__ import print_functionfrom collections import OrderedDictdef meminfo(): ''' Return the information in /proc/meminfo as a dictionary ''' meminfo=OrderedDict() with open('/proc/meminfo') as f: