Time of Update: 2016-12-02
標籤:rar 實現 記憶體 add 邏輯運算 test upper 程式 cti 一、範圍範圍在定義函數時就已經固定住了,不會隨著調用位置的改變而改變 二、匿名函數lamb
Time of Update: 2016-12-03
標籤:nbsp linu split pen error class rip close else 如下是作業,用python做一個ftp,主要利用socket。server端在linux下運行
Time of Update: 2016-12-03
標籤:local tin 介紹 異常 ota 抽象 decode code 附加 學習內容:Python模組介紹1、經典類 or
Time of Update: 2016-12-03
標籤:python zipzip函數接受任意多個(包括0個和1個)序列作為參數,返回一個tuple列表。具體意思不好用文字來表述,直接看樣本:1.樣本1:x = [1, 2, 3]y = [4, 5, 6]z = [7, 8, 9]xyz = zip(x, y, z)print xyz啟動並執行結果是:[(1, 4, 7), (
Time of Update: 2016-12-03
標籤:python loggingpython logging模組可能會令人困惑的地方通過參閱python logging模組的代碼,發現一些有趣的現象: 1. logging對象其實是一個樹形結構,每個建立的logging對象都是root logging對象的孩子結點。當使用logging模組的getLogger(name=None)函數構造logging對象的時候,如果name為None,這樣會產生一個root logging對象。如果name中含有.,比如name = ‘a.b.
Time of Update: 2016-12-03
標籤:小故事 英文 中文 記錄 程式 01的意義,一個小故事;多少位元字,比如20000多,即為2**15,即為15位01可以解釋20000多;字元編碼和01的關係;ASCIIGBK1.0GBK18030=GBKUnicode;UTF-8:英文一個位元組中文三個位元組從上往下發展python2預設使用ASCII,python3預
Time of Update: 2016-12-03
標籤:border if語句 pytho code module 意思 作用 from tab 很多新手剛開始學習python的時候經常會看到python 中__name__ =
Time of Update: 2016-12-03
列表產生式:List Comprehensions,是python中非常非常簡單但卻最常用的一個功能。根據名字就能知道,列表產生式所返回的應該是list類型,它能用最簡單最易懂的寫法產生所需要的列表。例:我需要得到1-100這個list的所有數的平方所組成的一個list。此時可以用for迴圈:Python代碼 a = [] for value in range(1, 101): a.append(value * value) print(a)
Time of Update: 2016-12-03
主要應用情境為:有變動需求的一次性定時任務。 通過redis到期事件的監聽,執行相應命令。(注意:因為監聽只能得到key, 所以需要另外儲存具體執行內容體) 另外記得修改redis配置:notify-keyspace-events Ex import redis rdc = redis.StrictRedis() pubsub = rdc.pubsub() pubsub.psubscribe("__keyevent@0__:expired")
Time of Update: 2016-12-03
通過qrcode產生二維碼網上教程的代碼都能用簡單粗暴import qrcode img = qrcode.make('http://lizhiyu.iteye.com/blog/2331662') img.save('test.png') 加參數控制Python代碼 import qrcode qr = qrcode.QRCode( version=1,
Time of Update: 2016-12-03
1.python 2.7.2(安裝版本) 2.MySQL-python-1.2.3.win32-py2.7 (mysqldb模組) #串連資料庫代碼 #coding=utf-8 import MySQLdb import sys import time host ='127.0.0.1' user ='root' passwd ='123456' port = 3306 db_list=[] tb_list=[]
Time of Update: 2016-12-03
set集合是一個無序且不重複的元素集合1.set的建立 2種方式: se = {11,22,33}se = set([11,22,33]) #調用的set的__init__方法進行建立2.set的常用方法1.add se = {11,22,33}se.add(44)print(se) => {33,11,44,22} #因為是無序的,所以執行的結果會不一樣,但是44確實被增加到了原set集合中 2.remove se = {11,22,33}se.remove(11)print (
Time of Update: 2016-12-03
運算子1、算數運算: +,-,*,/,%,**,//print (3+2) => 5print (3-2) => 1print (2*4) => 8print (9/3) => 3print (2**2) => 4print (100%51) => 49print (9//2) => 42、比較運算: ==,!=,<>,>,<,>=,<=print (3==2) => Falseprint (3!=2)
Time of Update: 2016-12-03
for迴圈:a = [11,22,33,44]for i in a: print (i)結果:11223344while迴圈:i=0while i < 3:#i<3為迴圈條件,當條件為真時,執行後面的迴圈體;條件為假時不執行 print (i) i += 1結果:012break和Continue:i= 0while i < 10: print ("i->:",i) if i == 5: break#當i==
Time of Update: 2016-12-03
1、list建立new_list1 = ['TV','Car','Cloth','Food']new_list2 = list(['TV','Car','Cloth','Food'])print (new_list1)print (new_list2)運行結果:['TV', 'Car', 'Cloth',
Time of Update: 2016-12-03
Linux 常用簡單命令,linux命令 安裝VMware時切記保持更新,重新安裝VMware tools,根據虛擬機器下方的提示完成。在Ubantu系統中額外安裝軟體,軟體格式是.deb,以sublime-text-3為例,直接從Windows中複製粘貼到/opt中,在終端中輸入sudo dpkg -i /opt/sublime-text-3.deb,即可。(終端在應用市場中找,當sublime安裝成功後,在終端輸入subl開啟)
Time of Update: 2016-12-03
簡介python2.x的編碼,簡介python2.x編碼python2.x的中文編碼真是令人頭痛,簡單寫下自己的一點python編碼轉換的體會。windows平台用的預設編碼格式為gbk>>> s = raw_input()#在windows平台下 s 的字元編碼就是gbk,若要轉換為utf-8,則必須藉助python內建對象Unicode作為中介u = s.encode('gbk')
Time of Update: 2016-12-03
[terry筆記]python FTP,terrypython如下是作業,用python做一個ftp,主要利用socket。server端在linux下運行,在client端可以執行shell命令(靜態)在client端輸入get xxx,即可下載。在client端輸入put xxx,即可上傳。 server端: 1 import socket 2 import subprocess 3 import os 4 server =
Time of Update: 2016-12-03
python virtualenv 安裝運行saltstack,saltstackenv需求產生情境: 1、python的virtualenv虛擬環境非常的好用。 2、saltstack作為營運自動化的一個重要組件也挺好用的。 但是: 1、saltsatck最簡便的是使用yum安裝,結合的是linux-centos內建的python2.6版本。
Time of Update: 2016-12-03
python中map()函數,python中map函數map()是 Python 內建的高階函數,它接收一個函數 f 和一個 list,並通過把函數 f 依次作用在 list 的每個元素上,得到一個新的 list 並返回。例如,對於list [1, 2, 3, 4, 5, 6, 7, 8, 9]如果希望把list的每個元素都作平方,就可以用map()函數:因此,我們只需要傳入函數f(x)=x*x,就可以利用map()函數完成這個計算:def f(x): return