註:需要安裝psutil庫原始碼如下:#!/usr/bin/env python## $Id: iotop.py 1160 2011-10-14 18:50:36Z g.rodola@gmail.com $## Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.# Use of this source code is governed by a BSD-style license that can be#
教為學:python學習之路(一):python源碼安裝前言Python是一門萬金油語言,特別在Linux下。一般的Linux系統也內建Python。不過,我們依舊有必要學習怎麼在Linux下安裝Python。作業系統的版本:gaopeng@gaopeng-virtual-machine:~$ uname -a Linux gaopeng-virtual-machine 3.2.0-38-generic #61-Ubuntu SMP Tue Feb 19 12:20:02 UTC 2013 i6
len和in的使用方法: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 #_*_ coding:utf-8 _*_ 2 #函數len返回列表的長度,即元素的個數 3 aa = [1,2,3,4,5] 4 print 'length of aa is ', len(aa) #result:length of aa is 5 5
英文原文:http://www.rafekettler.com/magicmethods.html#conclusion1.__new__ 是靜態方法(__new__ is a static method),執行個體化時以類作對象為第一個參數(The first argument to __new__ must be a class; the remainingarguments are the arguments as seen by the constructor
1, 異常文法try: <statement>except <name1>: <statement> # if name1 is raisedexcept <name2>: <statement> # if name2 is raisedexcept (name3, name4): <statement> # if name3 or name4 raisedexcept:
機器中毒,用autoruns把“Appinit DLLs” 、“Image hijacks”項目清除後,殘餘病毒檔案需要清除。觀察發現病毒檔案都不擁有版本資訊,於是乎用python刪除這些該死的檔案!步驟如下:> import ctypes, os> os.chdir(r'c:/windows/system32')> files = [f for f in os.listdir(os.curdir) if f.rfind('.dll') > 0]>
在C中修改容器中的每一個節點的內容我們的辦法只有一個,就是遍曆節點並對節點進行操作:for (int i = 0; i < len; ++i) { con[i] *= 2;}我們C++11一些(m是標準容器):for (auto i : m) { i *= 2;}或者foreach(m.begin(), m.end(), [](x){x*=2}); 很自然的在python中也會有人這樣去寫:for i in m: i = i *