Time of Update: 2014-08-14
標籤:des style blog http color 使用 os io 只是粗略的知道yield可以用來為一個函數傳回值塞資料,比如下面的例子:for i in alist: &nbs
Time of Update: 2014-08-14
標籤:des style blog http color os io for 本人的學習筆記主要記錄的是學習opencv-python-tutorials這本書中的筆記今天晚上簡單學習OpenCV for Python如何繪圖,
Time of Update: 2014-08-14
標籤:style blog color java strong 資料 for div python物件導向非常徹底,即使過程式的代碼風格,python在運作的時候也是物件導向的。everything is
Time of Update: 2018-12-08
開源的,地址在https://github.com/atupal/webqq 等有時間了寫一個完整的cli qq用戶端。 使用方法:python login_qq.py即可 複製代碼 代碼如下:import urllib2 import httplib2 import re import random from encryption import QQmd5 import cookielib import requests import getpass import time import
Time of Update: 2018-12-08
以下的文章主要是以介紹python隨機數產生的程式碼來介紹Python隨機數產生在實際操作過程中的具體應用,如果你對其的相關內容感興趣的話,你就可以點擊以下的文章。希望你會對它有所收穫。 Python中的random模組用於產生隨機數。下面介紹一下random模組中最常用的幾個函數。 複製代碼 代碼如下:random.randomrandom.random() 用於產生一個0到1的隨機符點數: 複製代碼 代碼如下:0 <= n <
Time of Update: 2018-12-08
列表解析 在需要改變列表而不是需要建立某列表時,可以使用列表解析。列表解析運算式為: [expr for iter_var in iterable] [expr for iter_var in iterable if cond_expr] 第一種文法:首先迭代iterable裡所有內容,每一次迭代,都把iterable裡相應內容放到iter_var中,再在運算式中應用該iter_var的內容,最後用運算式的計算值產生一個列表。
Time of Update: 2018-12-08
1. 設定fomat格式,如下: 複製代碼 代碼如下:# 取前5個字元,跳過4個字元華,再取3個字元 format = '5s 4x 3s' 2. 使用struck.unpack擷取子字串 複製代碼 代碼如下:import struct print struct.unpack(format, 'Test astring') #('Test', 'ing') 來個簡單的例子吧,有一個字串'He is not very happy',處理一下,把中間的not去掉,然後再輸出。 複製代碼
Time of Update: 2018-12-07
尋找半天能製作mht格式的方法,發現只有一個庫能完成目的,下載後驚呼有碼!出於對廣大男同胞痛恨註冊碼的體諒,放出破解方法供大家使用。chilkat公司做了好多模組都是有碼的,跟蹤了一下發現通過c寫了py擴充,然後在擴充裡做驗證。再做了一下系統對比,它通過寫註冊表來記錄日期,把日期經過編碼後丟到了一個地方,驗證目前時間是否超了30天。好吧,反正試用30天又沒有什麼限制,哥永遠都是18歲,永遠都是第一次。作者在建立子項名字留了一手?還斷行符號?調試半天才意識到keyopen
Time of Update: 2018-12-07
1. TypeError: coercing to Unicode: need string or buffer, type foundTraceback (most recent call last): File "unzip.py", line 20, in <module> tar = tarfile.open(file) File
Time of Update: 2018-12-07
#!/usr/bin/python#-*- coding:gbk-*-'''spec:根據是否命中126W人名,將usrdict分為兩個部分parms:[IN] [IN][OUT]author: liuyusi0121@sogou-inc.com date 20120808'''import re;import sys;def LoadKeys(filename): ''' 載入key到記憶體 ''' keys=[]; p=re.compile('^\s+|\s+$
Time of Update: 2018-12-07
1 setattr():setattr()表示你可以通過該方法,給對象添加或者修改指定的屬性。setattr()方法接受3個參數:setattr(對象,屬性,屬性的值)2 delattr():而delattr()表示你可以通過該方法,刪除指定的對象屬性。delattr方法接受2個參數:delattr(對象,屬性)下面是代碼的應用#encoding=utf-8class student(object): def __init__(self,name,age): self.name
Time of Update: 2018-12-07
python內部內建了一個單元測試的模組,pyUnit也就是我們說的:unittest先介紹下unittest的基本使用方法:1.import unittest2.定義一個繼承自unittest.TestCase的測試案例類3.定義setUp和tearDown,在每個測試案例前後做一些輔助工作。4.定義測試案例,名字以test開頭。5.一個測試案例應該只測試一個方面,測試目的和測試內容應很明確。主要是調用assertEqual、assertRaises等斷言方法判斷程式執行結果和預期值是否相符。
Time of Update: 2018-12-07
pygr - Scalable bioinformatics interfaces in Python - Google Project HostingWelcome to pygr!Pygr is open source software designed to make it easy to do powerful sequence and comparative genomics analyses, even with extremely large multi-genome data
Time of Update: 2018-12-07
一 web2py的應用的執行環境Models,Controllers和views所在的執行環境中,以下對象已經被預設地匯入:Global Objects: request,response,session,cacheNavigation: redirect,HTTPInternationalization: THelpers: XML, URL, BEAUTIFYA, B, BEAUTIFY, BODY, BR, CENTER, CODE, DIV, EM,
Time of Update: 2014-06-28
利用python開發了一個提取sim.log 中的各個關鍵步驟中的時間並進行統計的程式:#!/usr/bin/python2.6import re,datetimefile_name='/home/alzhong/logs/qtat1/R2860.01.13/sim-applycommitrollback-bld1.log'file=open(file_name,'r')acnum=[];time_res=[];lnum=0def trans_time(time)
Time of Update: 2014-03-21
happiness---xingyunpiAutomation Test plays an important role in our test work. Now I will record my work related to automation test, using Python to run REST API. Until now, I have design two kinds of test scenarios: parameter testing for each REST
Time of Update: 2014-03-09
1. python中常用的檔案操作有open,write,read,readline,readlines,writelines,seek,tell,close等。open的函數原型為open(name[,mode[,buffering]]),name為檔案的路徑名,常見的mode有’r’ (讀模式),’w’ (寫入模式),’a’追加模式,’b’ ( 二進位模式)
Time of Update: 2013-12-27
:下載粘貼一下 v0.2的代碼備用#!/usr/bin/env python""" A pure python ping implementation using raw socket. Note that ICMP messages can only be sent from processes running as root. Derived from ping.c distributed in Linux's netkit. That code is
Time of Update: 2013-12-27
最近痛感在叢集裡逐台部署ganglia, cacti這些監控的東西很麻煩,就寫了個小程式去批量自動部署。原理是通過python的pexpect用ssh去複製檔案和執行系統命令,我用它來部署ganglia等,但是其他的東西也可以通過這個指令碼來批量部署,只要自己編寫部署指令碼就可以了。主要是提出一個解決思路,看對大家是否有所協助。先約定一個概念,我們把放置python和指令碼的伺服器叫做主控節點或者server,把需要安裝的節點叫做受控節點或者client。以下均以server和client代稱。
Time of Update: 2013-12-27
Python常見部署方法有 :fcgi :用spawn-fcgi或者架構內建的工具對各個project分別產生監聽進程,然後和http 服務互動wsgi :利用http服務的mod_wsgi模組來跑各個project(Web應用程式或架構簡單而通用的Web伺服器 之間的介面)。uWSGI 是一款像php-cgi一樣監聽同一連接埠,進行統一管理和Server Load