Python学习足迹(4)(入门篇终结)

python种的标准库:

sys
sys.argv所有的参数。
import sys
if '-h' in sys.argv: print 'this is help\n'

sys.exit( exitcode), sys.exit(0)

sys.stdin, data=sys.stdin.readlines()
sys.stdout,
sys.stderr
sys.platform
sys.path,返回list

type
if type('abc') == types.StringType: (true)
if type('abc') == type( '' ) (true)

copy
copy.copy()浅copy
copy.deepcopy()深copy

string
string.split()
>>> import string
>>> string.split("a b c")
['a', 'b', 'c']
string.atoi(str,base)
string.atof(str)
string.atol(str,base)
string.upper()
string.lower()
string.find()找位置
string.join()合并
string.lstrip(), string.rstrip(), string.strip()
string.replace()

re正则表达式

os
os.environ['PATH'] ='/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/sbin/:.'
os.name  = 'posix'
os.getcwd()
os.listdir('/'),列出所有的dir
os.rename(oldfile, newfile)
os.chmod()
os.system('cmd'),执行命令
os.remove()
os.mkdir()
os.rmdir()
os.removedirs(),删除所有
os.path.exists(),是否存在?
os.path.isfile(),os.path.isdir()
os.path.split()
>>> os.path.split('/home/james/.vimrc')
('/home/james', '.vimrc')

time
time.time(),由Unix纪元(1970年首)到现在的秒数,UTC
time.localtime() = (2004, 8, 8, 23, 19, 53, 6, 221, 1), 年,月,日,小时,分钟,秒,周几,今年的第几天,夏时制
time.asctime() = 'Sun Aug  8 23:20:03 2004'
time.sleep()中断,秒数,象C#种的thread.sleep()

tempfile
tempfile.mktemp()产生一个临时文件


其他的库(日后研究)
mutex
signal
socket
thread
threading
zlib
gzip
urllib
httplib
ftplib
poplib
nntplib
smtplib
telnetlib
urlparse
socketserver
htmllib
xmllib
rfc82lib
base64
xdrlib(RPC)
md5
sha
posix
crypt

posted @ 2004-08-09 15:09  James  阅读(1016)  评论(0编辑  收藏  举报