python學習記錄

2021-05-24 06:29:45 字數 1886 閱讀 3553

python 3:

整除, 複數表示, slice, range, pass關鍵字, 函式用引數名呼叫,函式的*arg和**arg, 預設引數, unpacking argument lists, sequence 型別:list, set , tuple, dictionary,queue,stack; loop相關:enumurate, zip,reversed, sorted; sequence的順序比較

__name__, __main__, pyc, pyo, dir, __path__, package, __init__, __all__,str, repr, string.format, %, open, pickle, try-except [as]-else=finally, with, nonlocal, global, class doc string, class method object,  私有變數, 模擬c結構, __iter__, __next__, yield,__init__, __add__, __str__, __cmp__

python essiential reference 4th:

閉包, context management, decorator, generators and coroutines, generator expressions, declarative programming, lambda, eval, exec, compile, static methods and class methods, properties, descriptors, object memory management, object representation and attribute binding, __slots__, abstract base classes, metaclasses, namespace, module search path, program args, optparse,  fileinput module, distutils, py2exe,__del__

nonlocal, frame object, code object, traceback object, generator object, slice object, ellipsis object

python text process:

urllib2, re, enumurate, xrange, string.template用法和場合?mako, cheetah, zope page

templates, reportlab, xlwt,odf, pyparsing, nltk,nucular

map,reduce, filter, list comprehensive

python標準庫:

getopt 解析命令列

copy 物件拷貝

operator 操作符

sys python環境

types 型別

filecmp 檔案比較,可以比較大小,時間以及內容(可選)

fileinput 從命令列開啟多個檔案

glob 搜尋

os.path 檔案目錄路徑操作, os.path.walk可以遍歷資料夾

shutil shell操作,包括檔案拷貝等

tempfile 臨時檔案

commands 命令列

os 作業系統功能,主要os基本命令列都有對應,以及程序處理,命名管道處理

random 隨機數產生,也可以產生多個隨機分布數

struct 產生結構,用於呼叫c

time 時間函式

python的反射:

callable

getattr(obj, attrname)

python的and和or運算

python模擬c的?操作符

1 and a or b

0 and a or b

python學習記錄

python函式記錄 修飾符作用就是表示 下面的值或者函式作為 後面函式的引數 返回值由 後面的函式返回 map 接收乙個函式和乙個序列,然後保留函式返回的結果的序列 reduce 接收乙個函式和乙個序列 函式結果為乙個值,運算過程就是從序列的第乙個值開始傳給函式,返回結果再次傳入函式,直到最後得到...

python學習記錄

函式的作用 按照key對迭代器iterable進行分組 函式的返回 tuple,其中第乙個元素是groupby後的鍵值,第二個元素是乙個迭代器,包含那些被groupby的物件。第二個引數key是可選的,如果預設,那就按照iterable的每個元素分組。如果不預設,那應該是乙個函式,將iterable...

python學習記錄

numpy中的arange是左閉右開的 eg.a np.arange 2,10,2 輸出結果為 2 4 6 8 b np.linspace 2,10,2 預設是包含10的,但是可以通過endpoint false來取消 np.logspace 1,4,4,endpoint true,base 2 這...