Time of Update: 2015-06-22
標籤:一. install python1) check install or not在mac終端輸入命令:which python 即可查看python的路徑2)未安裝時,手動下載安裝包 地址:https://www.python.org/downloads/ 選擇下載 Mac OS X 64-bit/32-bit installer 安裝二. install twisted1) check install
Time of Update: 2015-06-29
標籤:1.基本用法#!/usr/bin/env python# coding=utf-8import re# example 1text ="fjsk test\t fjskd bar\t \ttest"regex = re.compile(‘\s+‘)print regex.split(text)# example 2email =""" [email protected] [email protected] [email protected]
Time of Update: 2015-06-29
標籤:python excel write excel with python xlwtinstallpip install xlwtxlwt.Workbook Object他有2個常用的方法,一個就是save 方法來儲存的,還有一個就是add_sheet 添加工作表。 1. save 2. add_sheetWorksheets Object是由Workbook這個對象建立出來的。可以直接write寫cell
Time of Update: 2015-06-29
標籤:字串輸入:my_string = raw_input("please input a word:")字串判斷:(1) 判斷是不是純字母my_string.isalpha()字串搜尋匹配:(1) rereRegex執行個體一:^[\w_]*$首先\w表示匹配包括底線的任何單詞字元,等價於‘[A-Za-z0-9_]‘。然後跟了個_。再看*號:匹配前面的子運算式零次或多次。例如,zo* 能匹配 "z" 以及 "zoo"。 * 等價於{0,}。最後是$:表示字串結束,後面沒有其他字元了。
Time of Update: 2015-06-29
標籤: 對於Python中靜態、類、抽象方法的使用,我是一直很迷糊的。最近看到一篇技術文章對這方面解釋的很好,在此翻譯一下,加深印象,也為有需要的同學提供一個方便。 Python中方法是如何工作的: 方法即函數,作為一個類的屬性儲存區。你能像如下申明和訪問一個函數:>>> class
Time of Update: 2015-06-28
標籤:python 營運自動化 大規模監控系統
Time of Update: 2015-06-28
標籤: Python中以雙底線開頭和結尾的函數稱為特殊函數,對於執行個體執行一些特定的運算時,Python會自動視圖調用這些執行個體的特殊方法,從而在Python中可以很輕易地實現運算子的重載。 Python中有一些通用的特殊函數: 1. 初始化與終止化 __new__(cls[,
Time of Update: 2015-06-27
標籤:python os system listdir canopy 1.字串string判斷一個字元(char)是數字還是字母 str.isalpha #判斷是否為字母str.isdigit #判斷是否為數字判斷一個字串是否為空白if not str.strip(): #判斷是否為空白,true表示空向字串新增內容str =
Time of Update: 2015-06-26
標籤:本文轉自:http://www.cnblogs.com/ifantastic/p/3175735.html __new__() 是在新式類中新出現的方法,它作用在構造方法建造執行個體之前,可以這麼理解,在 Python 中存在於類裡面的構造方法 __init__() 負責將類的執行個體化,而在 __init__() 啟動之前,__new__() 決定是否要使用該 __init__() 方法,因為__new__() 可以調用其他類的構造方法或者直接返回別的對象來作為本類的執行個體。
Time of Update: 2015-06-26
標籤:python如果匯入的模組不存在,Python解譯器會報 ImportError 錯誤:>>> import somethingTraceback (most recent call last): File "<stdin>", line 1, in <module>ImportError: No module named
Time of Update: 2015-06-26
標籤:>>> a = [‘ace‘,[‘age‘,10]]>>> b = a[:]>>> c = list(a)>>> for item in a:... print(id(item))... 140281621219736140281621134800>>> for item in b: print(id(item))... 1402816212197361402816211
Time of Update: 2015-06-26
標籤:pythonUDP通訊(python)client:importsockethost = ‘127.0.0.1‘port = 1024buff_size = 128addr = (host,port)udp_client = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)whileTrue: data =
Time of Update: 2015-06-25
標籤: 作為一個剛剛接觸python,第一次編程,第一次試著去做自動化的小渣渣,藉此地來見證自己的進步,也許每一步對於別人來說微不足道, 但是對於自己來說,是無數次思考之後才能邁出的一步,很吃力,也同樣很欣慰。廢話不多說,進入主題。 我用的是python+selenium webdriver來搭建自動化架構,對於python語言,不熟悉,只是粗略的看了一遍書,不知道該編什麼,也不知道怎麼編,請教大牛後,直接上路,不糾結,實戰中可以學會更多。推薦一本書,蟲師的《selenium
Time of Update: 2015-06-23
標籤:python hbase thrift網關 #pythonfrom thrift import Thriftfrom thrift.transport import TSocketfrom thrift.transport import TTransportfrom thrift.protocol import TBinaryProtocolfrom hbase import
Time of Update: 2015-06-24
標籤:python ftp快速進行ftp上傳 ,下載,查詢檔案利用Python實現ftp伺服器的操作#!/usr/bin/python#ftp.py#this script is used to make some ftp operations more convenient#add upload and download operations 20111210 version0.1import sys,os,ftplib,socketCONST_HOST = "your ftp
Time of Update: 2015-06-24
標籤:1.python中繼承的特點: (1)總是從一個類繼承,預設為object類 (2)不要忘記調用super.__init__方法來初始化父類的方法def __init__(self,args): super(Subclass,self).__init__(args) pass 簡單例子class Person(object): def __init__(self,name,gender): self.name = name
Time of Update: 2015-06-23
標籤:本人最近在寫一篇關於神經網路同步的文章,其一部分模型為:x_i^{\Delta}(t)= -a_i*x_i(t)+ b_i* f(x_i(t))+ \sum\limits_{j \in\{i-1, i+1\}}c_{ij}f(x_j(t-\tau_{ij})), t\in\mathbb{R} (1.1)y_i^{\Delta}(t)= -a_i*y_i(t)+ b_i* f(y_i(t))+ \sum\limits_{j \in\{i-1, i+1\}}c_{ij}f(y_j(t-\
Time of Update: 2015-06-25
標籤:研究python伺服器開發http://www.example-code.com/python/ssh_exec.asptelnet 118.193.152.71 51234import socket, threadingHOST = ‘127.0.0.1‘PORT = 51234 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.bind((HOST, PORT))s.listen(4)clients = [] #list
Time of Update: 2015-06-22
標籤:python 編程 學習《Python核心編程》做一下知識點提要,方便複習。電腦語言的本質是什嗎? a-z、A-Z、符號、數字等等組合成符合文法的字串,供編譯器、解譯器翻譯。 字母組合後產生各種變化拿python來說就是,關鍵字,數值,類,函數,運算子,操作符。。。。。。1.變數不用聲明,類型不固定 2.True,False = False,True讀出了什嗎?True是個bool()類執行個體
Time of Update: 2015-06-22
標籤:1、語句特性的一般定義:它們改變了事物。2、可以使用變數來引用函數。3、nan:not a number(非數值)4、str函數:把值轉換為合理形式的字串,repr函數會建立一個字串,它以合法的python運算式的形式來表示值。str、repr和反引號(``)是把python值轉換成字串的三種方法。 5、長字串(三引號)、原始字串(r‘‘)、Unicode(u‘‘) python-基礎教程筆記