Python-Lernhandbuch
/ Python內(nèi)置工具
Python內(nèi)置工具
內(nèi)置函數(shù)
str(string) 返回對象的字符串表示 list(seq) tuple(seq) int(x) 把字符串或數(shù)字轉(zhuǎn)換為整數(shù) long(x) float(x) Complex(real, image) hex(i) oct(i) ord(c) 返回單個(gè)字符的ascii值 chr(i) 返回ascii值為i的字符 min(i[, i]*) max(i[, i]*)
屬性操作函數(shù)
四個(gè)內(nèi)置函數(shù)分別對一個(gè)名字空間里的屬性做如下操作:是否存在,取值,設(shè)值,刪除??捎糜谀K,類和實(shí)例。
hasattr 有屬性則返回1,否則0 getattr setattr delattr
執(zhí)行程序
import exec code [in globaldict[, localdict]] compile(string, filename, kind) execfile(filename[, globaldict[, localdict]]) eval(code[, globaldict[, localdict]])
庫模塊
基本字符串操作:str模塊
高級(jí)的字符串操作:re模塊(正則表達(dá)式)
通用的操作系統(tǒng)接口:os模塊
拷貝文件和目錄:shutil模塊
Internat相關(guān)模塊:
公共網(wǎng)關(guān)接口:cgi模塊 操作URL: urllib和urlparse模塊 特殊的internet協(xié)議:httplib, ftplib, gopherlib, poplib, imaplib, nntplib, smtplib 處理internat文件的模塊:sgmllib, htmllib, xmllib, formatter, rfc822, mimetools, binhex, uu, binascii, xdrllib, mimetypes, base64, quopri, mailbox, mimify