Time of Update: 2014-08-10
標籤:如何問題: 1. Python數值有哪些? 2. 各類型的精度是多少? 3. 類型的轉換是如何?的? 5. 如何使用這些資料類型?需要注意什嗎? 6. 什麼是不可變類型? 數實值型別: 整型: (不可變類型) 標準整型:取值範圍[-sys.maxint-1, sys.maxint]
Time of Update: 2018-12-08
複製代碼 代碼如下:# _*_ coding:utf-8 _*_# name login_baidu.pyimport urllib,urllib2,httplib,cookielibdef auto_login_hi(url,name,pwd): url_hi="http://passport.baidu.com/?login" #設定cookie cookie=cookielib.CookieJar()
Time of Update: 2018-12-08
複製代碼 代碼如下:#!/usr/bin/python import sys def left_child(node): return node * 2 + 1 def right_child(node): return node * 2 + 2 def parent(node): if (node % 2): return (i - 1) / 2 else: return (i - 2) / 2 def max_heapify(array, i, heap_size): l =
Time of Update: 2018-12-08
Python版本 實現了比之前的xxftp更多更完善的功能 1、繼續支援多使用者 2、繼續支援虛擬目錄 3、增加支援使用者根目錄以及映射虛擬目錄的使用權限設定 4、增加支援限制使用者根目錄或者虛擬目錄的空間大小 xxftp的特點 1、開源、跨平台 2、簡單、易用 3、不需要資料庫 4、可擴充性超強 5、你可以免費使用xxftp假設自己的私人FTP伺服器 測試地址 ftp://xiaoxia.org 匿名帳號可以使用! 匿名根目錄唯讀,映射了一個虛擬目錄,可以上傳檔案但不允許更改! 使用方法
Time of Update: 2018-12-08
樣本可以附件中下載 1.載入xml檔案 載入XML檔案共有2種方法,一是載入指定字串,二是載入指定檔案 2.擷取element的方法 a) 通過getiterator b) 過 getchildren c) find方法 d) findall方法 樣本如下: 複製代碼 代碼如下:#-*- coding:utf-8 -*- from xml.etree import ElementTree def print_node(node): '''''列印結點基本資料''' print "========
Time of Update: 2018-12-08
為什麼會報錯“UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)”?本文就來研究一下這個問題。字串在Python內部的表示是unicode編碼,因此,在做編碼轉換時,通常需要以unicode作為中間編碼,即先將其他編碼的字串解碼(decode)成unicode,再從unicode編碼(encode)成另一種編碼。
Time of Update: 2018-12-08
複製代碼 代碼如下:class EntryDemo( Frame ): """Demonstrate Entrys and Event binding""" chosenrange = 2 url_login="http://.../ipgw/ipgw.ipgw/" uid = '' #使用者名稱 password = '' # 密碼 operation = '' # 操作 range = '2' # 範圍 the_page = '' # WEB伺服器返回頁面 # 表單的INPUT
Time of Update: 2018-12-08
局部名字靜態檢測 Python探測局部範圍的時候:是在python編譯代碼時檢測,而不是通過他們在運行時的賦值。 正常的情況下,沒在函數中複製的名字將在包含它的模組中尋找: >>> x=99 >>> def selector(): ... print x ... >>> selector() 99 但是: >>> def selector(): ... print x ... x=100 ... >>>
Time of Update: 2018-12-08
1. copy.copy 淺拷貝 只拷貝父物件,不會拷貝對象的內部的子物件。2. copy.deepcopy 深拷貝 拷貝對象及其子物件一個很好的例子:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->import copya = [1, 2, 3, 4, ['a', 'b']] #原始對象b = a #賦值,傳對象的引用c =
Time of Update: 2018-12-08
一、服務端(Server.py) 服務端要做的事情是: 1. 建立一個Socket對象Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->import sockets = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 2. 綁定一個連接埠Code highlighting
Time of Update: 2018-12-08
比如下面的例子:class Book(object): def __setattr__(self, name, value): if name == 'value': object.__setattr__(self, name, value - 100) else: object.__setattr__(self, name, value) def __getattr__(self, name):
Time of Update: 2018-12-08
比如,將一個字串轉換為一個字元數組: theList = list(theString) 同時,我們可以方便的通過for語句進行遍曆: for c in theString: do_something_with(c) 甚者,使用這樣的語句: result = [do_something_with(c) for c in theString if c == 'x']
Time of Update: 2018-12-08
常用的module是 os ,os.path 和shutil,所以要先引入他們. python遍曆檔案夾和檔案 這個也許是最常用的功能,如下: 複製代碼 代碼如下:import os import os.path rootdir = "D:\\programmer\\training" for parent, dirnames, filenames in os.walk(rootdir): #case 1: for dirname in dirnames:
Time of Update: 2018-12-08
實際效果:假設給定目錄"/media/data/programmer/project/python" ,備份路徑"/home/diegoyun/backup/“ , 則會將python目錄下的檔案按照全路經備份到備份路徑下,形如:/home/diegoyun/backup/yyyymmddHHMMSS/python/xxx/yyy/zzz.....複製代碼 代碼如下:import os import shutil import datetime def mainLogic():
Time of Update: 2018-12-08
1. 引用css。這可能是最常見的做法了,對一些特定的元素定義特定的樣式。那麼使用它,你需要在HTML 頁面中加入<link>標籤。 2. 引入js。許多特效也可以通過javascript來進行處理,比如動態顯示效果,或對元素進行封裝。使用 它你需要在HTML頁面加入<script>標籤,必要時還要加一些javascript代碼。 3. HTML元素。需要設定一些特殊的屬性,比如class=某個屬性。這塊還相對簡單。
Time of Update: 2018-12-08
今天因為給BeauBeau提供的抽獎號碼做SQL檔案,一開始收到ZIP檔案解開壓縮之後被嚇到了——29個CSV檔案,每個檔案儲存了1000個獎券ID和號碼-_-! 照上次一樣,開啟每個CSV檔案做先做單獨的SQL檔案,每個SQL中有1000條插入語句,隨後將29個檔案的所有SQL語句都複製粘貼到同一個總的SQL檔案中。
Time of Update: 2018-12-08
1 IDLE1.1 IDLE是python創初人Guido van Rossum使用python and Tkinter來建立的一個整合式開發環境。要使用IDLE必須安裝python and Tkinter。1.2 特性:自動縮排,彩色編碼,命令曆史(Alt+p,Alt+n)和單詞自動(Alt+/)完成。1.3
Time of Update: 2018-12-08
一個好的整合式開發環境,能很大地提高編程效率。所以,我得需要先找一個好的python 的開發工具。eclipse +pyDev, 感覺還不錯。我把安裝過程的關鍵點,詳細記錄於本文,以便自己和讀者日後重新安裝的時候,別找不到北。eclipse 是一個java的免費的IDE, 我安裝的是 eclipse-SDK-3.2.1-win32.zip,123M
Time of Update: 2014-07-15
centos7.0
Time of Update: 2014-05-21
python中使用Regex1. 匹配字元Regex中的元字元有 . ^ $ * + ? { } [ ] \ | ( )匹配字元用的模式有\d 匹配任一數字 \D 匹配任意非數字\s 匹配任意空白字元\S 匹配任意非空格字元 \w 匹配任一數字或者字母\W 匹配任意非數字或者字母 2. Regexpython中使用compile處理Regex,如:import re;p=re.compile(‘[a-c]’);p.match(s);s是待匹配的字串,