Time of Update: 2015-07-22
標籤:飛躍式發展的後現代Python世界 如果現代Python有一個標誌性特性,那麼簡單說來便是Python對自身定義的越來越模糊。在過去的幾年的許多項目都極大拓展了Python,並重建了“Python”本身的意義。 與此同時新技術的湧現侵佔了Python的份額,並帶來了新的優勢:Go - ( Goroutines, Types, Interfaces )Rust - ( Traits, Speed, Types )Julia - ( Speed, Types,
Time of Update: 2015-07-22
標籤:In Python, it‘s concise, easy and faster to swap 2 variables compared in other Programming languages:Python:x, y = y, xOther programming languages:temp = xx = yy = tempActually, we can also use the second method just like the other
Time of Update: 2015-07-22
標籤:harris 最常用作特徵檢測演算法。 第一個檔案harris.py<pre name="code" class="python">from scipy.ndimage import filtersfrom numpy import *from pylab import *def compute_harris_response(im,sigma=3):
Time of Update: 2015-07-22
標籤:1. 模組 在python中一個檔案可以被看成一個獨立模組,而包對應著檔案夾,模組把python代碼分成一些有組織的程式碼片段,通過匯入的方式實現代碼重用。1.1 模組搜尋路徑 匯入模組時,是按照sys.path變數的值搜尋模組,sys.path的值是包含每一個獨立路徑的列表,包含目前的目錄、python安裝目錄、PYTHONPATH環境變數,搜尋順序按照路徑在列表中的順序(一般目前的目錄優先順序最高)。1 >>> import sys2 >>>
Time of Update: 2015-07-22
標籤:名稱英文定義特點操作備忘列表Listlist是一種有序的集合,可以隨時添加和刪除其中的元素,用["A","B"]表示有序可修改,可以不同資料類型,下標從0開始,最後一個下標為-1。增:append(值) Insert(位 置,值)刪:remove(值)
Time of Update: 2015-07-22
標籤:import os os模組主要用於運行系統命令import osos.remname(‘file.txt‘,‘file1.txt‘) 檔案重新命名os.remove(‘file1.txt‘) 刪除檔案os.mkdir(‘test‘) 建立檔案夾os.rmdir(‘test‘) 刪除檔案夾os.sep 可以取代作業系統特定的路徑分割符os.getcwd()
Time of Update: 2015-07-22
標籤:pexect sshpython(pexpect)簡單的自動ssh指令碼# vi ssh.py#!/usr/bin/python按a或i進入編輯模式import pexpectchild=pexpect.spawn(‘ssh [email protected]‘)child.expect(‘password:‘)child.sendline(‘123456‘)child.interact()child.close()按Esc鍵退出編輯模式:wq(儲存並退出)# python
Time of Update: 2015-07-22
標籤:python 目錄遞迴遍曆 #實現目錄遞迴遍曆,尋找.log檔案,並將結果存入檔案import osres=[]def findfile(dir): for i in os.listdir(dir): if os.path.i
Time of Update: 2015-07-22
標籤:python中的列表、元祖、字典的區別定義方法列表可以包含不同類型的對象,可以增減元素,可以跟其他的列表結合或者把一個列表拆分,用[]來定義的eg:aList=[123,‘abc‘,4.56,[‘inner‘,‘list‘],7-9j]1.list(str):將str轉換成list類型,str可以使字串也可以是元群組類型2.aList.append(‘test‘):追加元素到列表中去3.del aList[1]:刪除列表中下標為1的元素del aList:刪除整個列表4.cmp(list1
Time of Update: 2015-07-22
標籤:python 異常處理 異常處理的目的是防止使用者看到不友好的異常情況,避免程式異常退出一.通過try...except...將異常截獲,保證程式繼續執行try: open(‘test.txt‘,‘r‘) 1/0except ZeroDivisionError,e: print
Time of Update: 2015-07-22
標籤:
Time of Update: 2015-07-22
標籤: ---------------------------------------------------------------------------------shutil 實用模組包含了一些用於複製檔案和檔案夾的函數. copy 函數使用和 Unix 下 cp 命令基本相同的方式複製一個檔案.---------------------------------------------------------------------------
Time of Update: 2015-07-22
標籤:如何捅破python編程的那層紙之二# coding:utf-8"""如何捅破python編程的那層紙之二貼吧上有人問定義一個函數,名字為sameSums(aList),alist是一個整形list,函數作用是判斷能分成兩組,使得兩組數位和相等。若可以擇傳回值是true,若不可以傳回值是false。如下例:sameSums([4, 7, 6, 3]) --> True //4+6 = 10 and 7 + 3 = 10sameSums([3, 3]) -->
Time of Update: 2015-07-22
標籤:最新安裝方式# wget https://bootstrap.pypa.io/get-pip.py# python get-pip.py //
Time of Update: 2015-07-22
標籤:Python 字串操作去空格及特殊符號s.strip().lstrip().rstrip(‘,‘)複製字串#strcpy(sStr1,sStr2)sStr1 = ‘strcpy‘sStr2 = sStr1sStr1 = ‘strcpy2‘print sStr2連接字串#strcat(sStr1,sStr2)sStr1 = ‘strcat‘sStr2 = ‘append‘sStr1 += sStr2print sStr1尋找字元#strchr(sStr1,sStr2)# < 0
Time of Update: 2015-07-22
標籤:python 字串 please star 輸入x = 3print(x)age=input(“please input string:”)input函數的使用650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/6F/F4/wKioL1WuYASg776CAAFbPjcNOrU547.jpg"
Time of Update: 2015-07-22
標籤:網路編程 python import 第三方 數學 1、系統庫提供內建函式(官方提供)字元函數庫(help(str)來查看具體的函數)數學函數庫(import math首先需要匯入庫,help(math)來查看具體的函數)OS函數庫(import
Time of Update: 2015-07-22
標籤:1.開啟檔案 open(name[mode[,buffing]) 參數: 檔案,模式,緩衝1)name: 是強制選項,模式和緩衝是可選的#如果檔案不在,會報下面錯誤1 >>> f = open(r‘D:\text.txt‘,‘r‘) 2 Traceback (most recent call last): 3 File "<stdin>", line 1, in <module> 4
Time of Update: 2015-07-22
標籤:windows system python linux import 我們從作業系統的的層次去學習os函數庫的基本知識: 1、作業系統的類型 &nb
Time of Update: 2015-07-22
標籤:1.下載軟體並配置 (1) 需要軟件:python2.7.10 和 PyCharm3.4.1,地址略,百度一大把的 (2) 安裝python2.7.10 下一步一直下去,直到安裝成功,我這裡放在D:\Program Files\Python27