Python學習足跡(4)(入門篇終結)

來源:互聯網
上載者:User

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()

reRegex

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.