绾跨▼鍒囨崲
json搴�
tornado寮傛璇锋眰
tornado.web.asynchronous杩欎釜瑁呴グ鍣� ioloop
a 36聽 21聽 21 15聽 15 6 6 3 3 0
鍧� 绫� 鍑芥暟
with聽 涓婁笅鏂囩鐞嗗櫒__enter__() 鍜� __exit__() 鏂规硶聽 contextlib 妯″潡聽 鑷畾涔変笂涓嬫枃绠$悊鍣�
Python鏍稿績缂栫▼锛宲ython绠�鏄庢暀绋�
WSGI 鍜� FastCGI 鐨勫叧绯�
CGI鍏ㄧО鏄�滃叕鍏辩綉鍏虫帴鍙b��(CommonGateway Interface)锛孒TTP鏈嶅姟鍣ㄤ笌浣犵殑鎴栧叾瀹冩満鍣ㄤ笂鐨勭▼搴忚繘琛屸�滀氦璋堚�濈殑涓�绉嶅伐鍏凤紝鍏剁▼搴忛』杩愯鍦ㄧ綉缁滄湇鍔″櫒涓娿��
FastCGI鍍忔槸涓�涓父椹�(long-live)鍨嬬殑CGI锛屽畠鍙互涓�鐩存墽琛岀潃锛屽彧瑕佹縺娲诲悗锛屼笉浼氭瘡娆¢兘瑕佽姳璐规椂闂村幓fork涓�娆�(杩欐槸CGI鏈�涓轰汉璇熺梾鐨刦ork-and-execute妯″紡)銆�
WSGI鐨勫叏绉颁负锛� PythonWeb Server Gateway Interface v1.0 锛圥ython Web 鏈嶅姟鍣ㄧ綉鍏虫帴鍙o級锛�
瀹冩槸 Python 搴旂敤绋嬪簭鍜� WEB 鏈嶅姟鍣ㄤ箣闂寸殑涓�绉嶆帴鍙c��
Tornado
瀹冩槸闈為樆濉炲紡鏈嶅姟鍣紝鑰屼笖閫熷害鐩稿綋蹇�傚緱鍒╀簬鍏� 闈為樆濉炵殑鏂瑰紡鍜屽epoll鐨勮繍鐢�
Http鍗忚
瑙勫畾浜嗘祻瑙堝櫒鍜屼竾缁寸綉鏈嶅姟鍣ㄤ箣闂翠簰鐩搁�氫俊鐨勮鍒欙紝閫氳繃鍥犵壒缃戜紶閫佷竾缁寸綉鏂囨。鐨勬暟鎹紶閫佸崗璁�傛槸涓�涓簲鐢ㄧ▼搴忕骇鐨勫熀浜嶵CP / IP鍗忚锛屽垎甯冨紡锛屽崗浣滐紝瓒呭獟浣撲俊鎭郴缁燂紙浜掕仈缃戯級銆�
HTTP鏄竴涓睘浜庡簲鐢ㄥ眰鐨勯潰鍚戝璞$殑鍗忚锛岀敱浜庡叾绠�鎹枫�佸揩閫熺殑鏂瑰紡锛岄�傜敤浜庡垎甯冨紡瓒呭獟浣撲俊鎭郴缁熴��
HTTP鍗忚鐨勪富瑕佺壒鐐瑰彲姒傛嫭濡備笅锛�
1.鏀寔瀹㈡埛/鏈嶅姟鍣ㄦā寮忋��
2.绠�鍗曞揩閫燂細瀹㈡埛鍚戞湇鍔″櫒璇锋眰鏈嶅姟鏃讹紝鍙渶浼犻�佽姹傛柟娉曞拰璺緞銆傝姹傛柟娉曞父鐢ㄧ殑鏈塆ET銆丠EAD銆丳OST銆傛瘡绉嶆柟娉曡瀹氫簡瀹㈡埛涓庢湇鍔″櫒鑱旂郴鐨勭被鍨嬩笉鍚屻�傜敱浜嶩TTP鍗忚绠�鍗曪紝浣垮緱HTTP鏈嶅姟鍣ㄧ殑绋嬪簭瑙勬ā灏忥紝鍥犺�岄�氫俊閫熷害寰堝揩銆�
3.鐏垫椿锛欻TTP鍏佽浼犺緭浠绘剰绫诲瀷鐨勬暟鎹璞°�傛鍦ㄤ紶杈撶殑绫诲瀷鐢盋ontent-Type鍔犱互鏍囪銆�
4.鏃犺繛鎺ワ細鏃犺繛鎺ョ殑鍚箟鏄檺鍒舵瘡娆¤繛鎺ュ彧澶勭悊涓�涓姹傘�傛湇鍔″櫒澶勭悊瀹屽鎴风殑璇锋眰锛屽苟鏀跺埌瀹㈡埛鐨勫簲绛斿悗锛屽嵆鏂紑杩炴帴銆傞噰鐢ㄨ繖绉嶆柟寮忓彲浠ヨ妭鐪佷紶杈撴椂闂淬��
5.鏃犵姸鎬侊細HTTP鍗忚鏄棤鐘舵�佸崗璁�傛棤鐘舵�佹槸鎸囧崗璁浜庝簨鍔″鐞嗘病鏈夎蹇嗚兘鍔涖�傜己灏戠姸鎬佹剰鍛崇潃濡傛灉鍚庣画澶勭悊闇�瑕佸墠闈㈢殑淇℃伅锛屽垯瀹冨繀椤婚噸浼狅紝杩欐牱鍙兘瀵艰嚧姣忔杩炴帴浼犻�佺殑鏁版嵁閲忓澶с�傚彟涓�鏂归潰锛屽湪鏈嶅姟鍣ㄤ笉闇�瑕佸厛鍓嶄俊鎭椂瀹冪殑搴旂瓟灏辫緝蹇��
Http璇锋眰澶村拰甯歌鍝嶅簲鐘舵�佺爜
HTTP 1.1涓姞鍏ヤ簡鈥淗ost鈥濊姹傚ご瀛楁聽 鏀寔闀胯繛鎺�
2xx锛氭垚鍔�--琛ㄧず璇锋眰宸茶鎴愬姛鎺ユ敹銆佺悊瑙c�佹帴鍙�
4xx锛氬鎴风閿欒--璇锋眰鏈夎娉曢敊璇垨璇锋眰鏃犳硶瀹炵幇
瑁呴グ鍣�
聽 聽 闈㈠悜鍒囬潰缂栫▼AOP
def聽deco(func):
聽聽聽聽def聽_deco():
聽聽聽聽聽聽聽聽print("before myfunc() called.")
聽聽聽聽聽聽聽聽func()
聽聽聽聽聽聽聽聽print("聽 after myfunc() called.")
聽聽聽聽聽聽聽聽# 涓嶉渶瑕佽繑鍥瀎unc锛屽疄闄呬笂搴旇繑鍥炲師鍑芥暟鐨勮繑鍥炲��
聽聽聽聽return聽_deco
@deco
def聽myfunc():
聽聽聽聽print(" myfunc() called.")
聽聽聽聽return聽'ok'
myfunc()
python鍙傛暟
*args聽and聽**kwargs
def funcC(a, b=0):聽 funcB(a=100, b=99)聽 def funcD(a, b, *c):
蹇呴』鍙傛暟聽 缂虹渷鍙傛暟聽 鍙彉鍙傛暟tuple 鍏抽敭瀛楀弬鏁癲ict
鐢�*args鍜�**kwargs鍙槸涓轰簡鏂逛究骞舵病鏈夊己鍒朵娇鐢ㄥ畠浠�.
褰撲綘涓嶇‘瀹氫綘鐨勫嚱鏁伴噷灏嗚浼犻�掑灏戝弬鏁版椂浣犲彲浠ョ敤*args.渚嬪,瀹冨彲浠ヤ紶閫掍换鎰忔暟閲忕殑鍙傛暟:
Python
1
2
3
4
5
6
7
8
>>> def print_everything(*args):
for count, thing in enumerate(args):
... print '{0}. {1}'.format(count, thing)
...
>>> print_everything('apple', 'banana', 'cabbage')
0. apple
1. banana
2. cabbage
鐩镐技鐨�,**kwargs鍏佽浣犱娇鐢ㄦ病鏈変簨鍏堝畾涔夌殑鍙傛暟鍚�:
Python
1
2
3
4
5
6
7
>>> def table_things(**kwargs):
... for name, value in kwargs.items():
... print '{0} = {1}'.format(name, value)
...
>>> table_things(apple = 'fruit', cabbage = 'vegetable')
cabbage = vegetable
apple = fruit
python 涓嶉渶瑕侀噸杞�
鍑芥暟閲嶈浇涓昏鏄负浜嗚В鍐充袱涓棶棰樸��
鍙彉鍙傛暟绫诲瀷銆偮� 聽 python 鍙互鎺ュ彈浠讳綍绫诲瀷鐨勫弬鏁�
鍙彉鍙傛暟涓暟銆偮� 聽 缂虹渷鍙傛暟
鏂板紡绫诲拰鏃у紡绫�
鏂板紡绫绘槸骞垮害浼樺厛,鏃у紡绫绘槸娣卞害浼樺厛)聽
缁ф壙object鐨勬槸鏂板紡绫�
__new__鍜宊_init__鐨勫尯鍒�
__new__鏄竴涓潤鎬佹柟娉�,鑰宊_init__鏄竴涓疄渚嬫柟娉�.
new鏂规硶浼氳繑鍥炴墍鏋勯�犵殑瀵硅薄锛宨nit鍒欎笉浼�.
new鍑芥暟蹇呴』浠ls浣滀负绗竴涓弬鏁帮紝鑰宨nit鍒欎互self浣滀负鍏剁涓�涓弬鏁�.
鍗曚緥妯″紡
瑁呴グ鍣ㄧ増鏈�
def singleton(cls, *args, **kw):
聽聽聽聽instances = {}
聽聽聽聽def getinstance():
聽聽聽聽聽聽聽聽if cls not in instances:
聽聽聽聽聽聽聽聽聽聽聽聽instances[cls] = cls(*args, **kw)
聽聽聽聽聽聽聽聽return instances[cls]
聽聽聽聽return getinstance
@singleton
class MyClass:
class Singleton(object):
__instance=None
def__init__(self):
pass
def__new__(cls,*args,**kwd):
if Singleton.__instance is None:
Singleton.__instance=object.__new__(cls,*args,**kwd)
return Singleton.__instance
import鏂规硶
浣滀负python鐨勬ā鍧楁槸澶╃劧鐨勫崟渚嬫ā寮�
Python
1
2
3
4
5
6
7
8
9
10
11
# mysingleton.py
class My_Singleton(object):
def foo(self):
pass
my_singleton = My_Singleton()
# to use
from mysingleton import my_singleton
my_singleton.foo()
@classmethod聽 聽 @staticmethod聽 @property杩欎笁涓楗板櫒鐨勪娇鐢ㄥ璞℃槸鍦ㄧ被涓畾涔夌殑鍑芥暟聽 property鎶婁竴涓柟娉曞彉鎴愬睘鎬ц皟鐢紝閫氬父鐢ㄥ湪灞炴�х殑get鏂规硶鍜宻et鏂规硶锛�閫氳繃璁剧疆@property鍙互瀹炵幇瀹炰緥鎴愬憳鍙橀噺鐨勭洿鎺ヨ闂�锛屽張淇濈暀浜嗗弬鏁扮殑妫�鏌ャ��
鏈楗扮殑鏂规硶杩樻槸姝e父鐨勮涓烘柟寮忥紝闇�瑕佸綋鍓嶇殑绫诲疄渚嬶紙self锛変綔涓虹涓�涓弬鏁般��
绫绘柟娉曠殑绗竴涓弬鏁版案杩滄槸璇ョ被
闈欐�佹柟娉曪紙static method锛変腑闄や簡浣犺皟鐢ㄦ椂浼犲叆鐨勫弬鏁颁互澶栵紝娌℃湁鍏朵粬鐨勫弬鏁般��
@property鏄疄鐜癵etter鍜宻etter鏂规硶鐨勪竴绉嶆柟寮忋�傜洿鎺ヨ皟鐢ㄥ畠浠槸閿欒鐨勩��
# 鈥滃彧璇烩�濆睘鎬у彲浠ラ�氳繃鍙畾涔塯etter鏂规硶锛屼笉瀹氫箟setter鏂规硶瀹炵幇銆�
class MyClass:
...
聽 @classmethod聽 # classmethod鐨勪慨楗扮聽 def class_method(cls, arg1, arg2, ...):
聽 ...
聽 @staticmethod聽 # staticmethod鐨勪慨楗扮聽 def static_method(arg1, arg2, ...):
聽 ...
瀵逛簬classmethod鐨勫弬鏁帮紝闇�瑕侀殣寮忓湴浼犻�掔被鍚嶏紝鑰宻taticmethod鍙傛暟涓垯涓嶉渶瑕佷紶閫掔被鍚嶏紝鍏跺疄杩欏氨鏄簩鑰呮渶澶х殑鍖哄埆銆�
Python涓殑浣滅敤鍩�
Python 涓紝涓�涓彉閲忕殑浣滅敤鍩熸�绘槸鐢卞湪浠g爜涓璧嬪�肩殑鍦版柟鎵�鍐冲畾鐨勩��
褰� Python 閬囧埌涓�涓彉閲忕殑璇濅粬浼氭寜鐓ц繖鏍风殑椤哄簭杩涜鎼滅储锛�
鏈湴浣滅敤鍩燂紙Local锛夆啋褰撳墠浣滅敤鍩熻宓屽叆鐨勬湰鍦颁綔鐢ㄥ煙锛圗nclosing locals锛夆啋鍏ㄥ眬/妯″潡浣滅敤鍩燂紙Global锛夆啋鍐呯疆浣滅敤鍩燂紙Built-in锛�
GIL绾跨▼鍏ㄥ眬閿�
绾跨▼鍏ㄥ眬閿�(Global Interpreter Lock),鍗砅ython涓轰簡淇濊瘉绾跨▼瀹夊叏鑰岄噰鍙栫殑鐙珛绾跨▼杩愯鐨勯檺鍒�,璇寸櫧浜嗗氨鏄竴涓牳鍙兘鍦ㄥ悓涓�鏃堕棿杩愯涓�涓嚎绋�.
鍗忕▼
绠�鍗曠偣璇村崗绋嬫槸杩涚▼鍜岀嚎绋嬬殑鍗囩骇鐗�,杩涚▼鍜岀嚎绋嬮兘闈复鐫�鍐呮牳鎬佸拰鐢ㄦ埛鎬佺殑鍒囨崲闂鑰岃�楄垂璁稿鍒囨崲鏃堕棿,鑰屽崗绋嬪氨鏄敤鎴疯嚜宸辨帶鍒跺垏鎹㈢殑鏃舵満,涓嶅啀闇�瑕侀櫡鍏ョ郴缁熺殑鍐呮牳鎬�.
Python閲屾渶甯歌鐨剏ield灏辨槸鍗忕▼鐨勬�濇兂!
闂寘
蹇呴』鏈変竴涓唴宓屽嚱鏁�
鍐呭祵鍑芥暟蹇呴』寮曠敤澶栭儴鍑芥暟涓殑鍙橀噺
澶栭儴鍑芥暟鐨勮繑鍥炲�煎繀椤绘槸鍐呭祵鍑芥暟
鍖垮悕鍑芥暟
>>> map(lambda x: x * x, [1, 2, 3, 4, 5, 6, 7, 8, 9])
[1, 4, 9, 16, 25, 36, 49, 64, 81]
>>> f = lambda x: x * x
>>> f
at 0x10453d7d0>
>>> f(5)
25
def build(x, y):
聽 聽 return lambda: x * x + y * y
鍋忓嚱鏁�
functools.partial灏辨槸甯姪鎴戜滑鍒涘缓涓�涓亸鍑芥暟鐨勶紝涓嶉渶瑕佹垜浠嚜宸卞畾涔塱nt2()锛屽彲浠ョ洿鎺ヤ娇鐢ㄤ笅闈㈢殑浠g爜鍒涘缓涓�涓柊鐨勫嚱鏁癷nt2锛�
>>> import functools>>> int2 = functools.partial(int, base=2)>>> int2('1000000')64>>> int2('1010101')85
楂橀樁鍑芥暟聽 鍑芥暟寮忕紪绋�
鏃㈢劧鍙橀噺鍙互鎸囧悜鍑芥暟锛屽嚱鏁扮殑鍙傛暟鑳芥帴鏀跺彉閲忥紝閭d箞涓�涓嚱鏁板氨鍙互鎺ユ敹鍙︿竴涓嚱鏁颁綔涓哄弬鏁帮紝杩欑鍑芥暟灏辩О涔嬩负楂橀樁鍑芥暟銆�
def add(x, y, f):
聽 聽 return f(x) + f(y)
x ==> -5y ==> 6f ==> abs
f(x) + f(y) ==> abs(-5) + abs(6) ==> 11
map
>>> def f(x):...聽 聽 return x * x
...>>> map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])
[1, 4, 9, 16, 25, 36, 49, 64, 81]
reduce
>>> def add(x, y):...聽 聽 return x + y
...>>> reduce(add, [1, 3, 5, 7, 9])25
filter
def is_odd(n):
聽 聽 return n % 2 == 1filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15])# 缁撴灉: [1, 5, 9, 15]
鍐呯疆妯″潡鍜岀涓夋柟妯″潡
os,sys,urllib,urllib2,re,json锛宑opy锛宺andom锛� itertools锛宖unctools锛宻hutil锛宲ickle锛宻qlite3,string,gzip,csv,hashlib,md5,io ,time,platform,select,threading,subprocess,xmldom,cookie,parser
lxml聽 etree锛宑ollection
绗笁鏂瑰簱
BeautifulSoup锛寈lwt锛堢敤浜庡皢鏁版嵁鍐欏埌excel鏂囦欢锛夛紝scrapy锛宲yspider锛孭IL锛堢敤浜庡鐞嗗浘鍍忔柟闈㈢殑鍥惧舰搴擄級
Numpy锛氶珮闃跺ぇ閲忕殑鐭╅樀杩愮畻锛宲ip锛宒jango锛寃ebpy锛宼wisted锛宲yqt锛宮ySQLdb锛宲y2exe锛岀敤浜庣敓鎴愭枃鏈殑妯℃澘宸ュ叿Jinja2锛宭ogging锛宻park锛宲ymango锛宖lask锛宻elenium锛宮atplotlib 鐢诲浘锛実event聽 锛宔xcept锛宻ched
Python鎵�鏈夌殑鍐呯疆鍑芥暟
Built-in Functions
abs()divmod()input()open()staticmethod()
all()enumerate()int()ord()str()
any()eval()isinstance()pow()sum()
basestring()execfile()issubclass()print()super()
bin()file()iter()property()tuple()
bool()filter()len()range()type()
bytearray()float()list()raw_input()unichr()
callable()format()locals()reduce()unicode()
chr()frozenset()long()reload()vars()
classmethod()getattr()map()repr()xrange()
cmp()globals()max()reversed()zip()
compile()hasattr()memoryview()round()__import__()
complex()hash()min()set()apply()
delattr()help()next()setattr()buffer()
dict()hex()object()slice()coerce()
dir()id()oct()sorted()intern()
re
# encoding: UTF-8
import聽re
# 灏嗘鍒欒〃杈惧紡缂栬瘧鎴怭attern瀵硅薄
pattern =聽re.compile(r'hello')
# 浣跨敤Pattern鍖归厤鏂囨湰锛岃幏寰楀尮閰嶇粨鏋滐紝鏃犳硶鍖归厤鏃跺皢杩斿洖None
match =聽pattern.match('hello world!')
if聽match:
聽聽聽聽# 浣跨敤Match鑾峰緱鍒嗙粍淇℃伅
聽聽聽聽print聽match.group()
### 杈撳嚭 ###
# hello
copy 鍜宒eepcopy
娴呭鍒跺彧澶嶅埗瀵硅薄鏈韩锛屾病鏈夊鍒惰瀵硅薄鎵�寮曠敤鐨勫璞°��
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#coding=gbk
import copy
l1 = [1, 2, [3, 4]]
l2 = copy.copy(l1)
print l1
print l2
l2[2][0] = 50
print l1
print l2
#---- 缁撴灉 ----
[1, 2, [3, 4]]
[1, 2, [3, 4]]
[1, 2, [50, 4]]
[1, 2, [50, 4]]
鍚屾牱鐨勪唬鐮侊紝浣跨敤娣卞鍒讹紝缁撴灉灏变笉涓�鏍凤細
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
import copy
l1 = [1, 2, [3, 4]]
l2 = copy.deepcopy(l1)
print l1
print l2
l2[2][0] = 50
print l1
print l2
#---- 缁撴灉 ----
[1, 2, [3, 4]]
[1, 2, [3, 4]]
[1, 2, [3, 4]]
[1, 2, [50, 4]]
import copy
a = [1, 2, 3, 4, ['a', 'b']]聽聽#鍘熷瀵硅薄
b = a聽聽#璧嬪�硷紝浼犲璞$殑寮曠敤
c = copy.copy(a)聽聽#瀵硅薄鎷疯礉锛屾祬鎷疯礉
d = copy.deepcopy(a)聽聽#瀵硅薄鎷疯礉锛屾繁鎷疯礉
a.append(5)聽聽#淇敼瀵硅薄a
a[4].append('c')聽聽#淇敼瀵硅薄a涓殑['a', 'b']鏁扮粍瀵硅薄
print 'a = ', a
print 'b = ', b
print 'c = ', c
print 'd = ', d
杈撳嚭缁撴灉锛�
a =聽聽[1, 2, 3, 4, ['a', 'b', 'c'], 5]
b =聽聽[1, 2, 3, 4, ['a', 'b', 'c'], 5]
c =聽聽[1, 2, 3, 4, ['a', 'b', 'c']]
d =聽聽[1, 2, 3, 4, ['a', 'b']]
os鍜宻ys
os妯″潡璐熻矗绋嬪簭涓庢搷浣滅郴缁熺殑浜や簰锛屾彁渚涗簡璁块棶鎿嶄綔绯荤粺搴曞眰鐨勬帴鍙�;sys妯″潡璐熻矗绋嬪簭涓�Python瑙i噴鍣ㄧ殑浜や簰锛屾彁渚涗簡涓�绯诲垪鐨勫嚱鏁板拰鍙橀噺锛岀敤浜庢搷鎺ython鐨勮繍琛屾椂鐜銆�
os 甯哥敤鏂规硶
os.remove(鈥榩ath/filename鈥�) 鍒犻櫎鏂囦欢
os.rename(oldname, newname) 閲嶅懡鍚嶆枃浠�
os.walk() 鐢熸垚鐩綍鏍戜笅鐨勬墍鏈夋枃浠跺悕
os.chdir('dirname') 鏀瑰彉鐩綍
os.mkdir/makedirs('dirname')鍒涘缓鐩綍/澶氬眰鐩綍
os.rmdir/removedirs('dirname') 鍒犻櫎鐩綍/澶氬眰鐩綍
os.listdir('dirname') 鍒楀嚭鎸囧畾鐩綍鐨勬枃浠�
os.getcwd() 鍙栧緱褰撳墠宸ヤ綔鐩綍
os.chmod() 鏀瑰彉鐩綍鏉冮檺
os.path.basename(鈥榩ath/filename鈥�) 鍘绘帀鐩綍璺緞锛岃繑鍥炴枃浠跺悕
os.path.dirname(鈥榩ath/filename鈥�) 鍘绘帀鏂囦欢鍚嶏紝杩斿洖鐩綍璺緞
os.path.join(path1[,path2[,...]]) 灏嗗垎绂荤殑鍚勯儴鍒嗙粍鍚堟垚涓�涓矾寰勫悕
os.path.split('path') 杩斿洖( dirname(), basename())鍏冪粍
os.path.splitext() 杩斿洖 (filename, extension) 鍏冪粍
os.path.getatime\ctime\mtime 鍒嗗埆杩斿洖鏈�杩戣闂�佸垱寤恒�佷慨鏀规椂闂�
os.path.getsize() 杩斿洖鏂囦欢澶у皬
os.path.exists() 鏄惁瀛樺湪
os.path.isabs() 鏄惁涓虹粷瀵硅矾寰�
os.path.isdir() 鏄惁涓虹洰褰�
os.path.isfile() 鏄惁涓烘枃浠�
sys 甯哥敤鏂规硶
sys.argv 鍛戒护琛屽弬鏁癓ist锛岀涓�涓厓绱犳槸绋嬪簭鏈韩璺緞
sys.modules.keys() 杩斿洖鎵�鏈夊凡缁忓鍏ョ殑妯″潡鍒楄〃
sys.exc_info() 鑾峰彇褰撳墠姝e湪澶勭悊鐨勫紓甯哥被,exc_type銆乪xc_value銆乪xc_traceback褰撳墠澶勭悊鐨勫紓甯歌缁嗕俊鎭�
sys.exit(n) 閫�鍑虹▼搴忥紝姝e父閫�鍑烘椂exit(0)
sys.hexversion 鑾峰彇Python瑙i噴绋嬪簭鐨勭増鏈�硷紝16杩涘埗鏍煎紡濡傦細0x020403F0
sys.version 鑾峰彇Python瑙i噴绋嬪簭鐨勭増鏈俊鎭�
sys.maxint 鏈�澶х殑Int鍊�
sys.maxunicode 鏈�澶х殑Unicode鍊�
sys.modules 杩斿洖绯荤粺瀵煎叆鐨勬ā鍧楀瓧娈碉紝key鏄ā鍧楀悕锛寁alue鏄ā鍧�
sys.path 杩斿洖妯″潡鐨勬悳绱㈣矾寰勶紝鍒濆鍖栨椂浣跨敤PYTHONPATH鐜鍙橀噺鐨勫��
sys.platform 杩斿洖鎿嶄綔绯荤粺骞冲彴鍚嶇О
sys.stdout 鏍囧噯杈撳嚭
sys.stdin 鏍囧噯杈撳叆
sys.stderr 閿欒杈撳嚭
sys.exc_clear() 鐢ㄦ潵娓呴櫎褰撳墠绾跨▼鎵�鍑虹幇鐨勫綋鍓嶇殑鎴栨渶杩戠殑閿欒淇℃伅
sys.exec_prefix 杩斿洖骞冲彴鐙珛鐨刾ython鏂囦欢瀹夎鐨勪綅缃�
sys.byteorder 鏈湴瀛楄妭瑙勫垯鐨勬寚绀哄櫒锛宐ig-endian骞冲彴鐨勫�兼槸'big',little-endian骞冲彴鐨勫�兼槸'little'
sys.copyright 璁板綍python鐗堟潈鐩稿叧鐨勪笢瑗�
sys.api_version 瑙i噴鍣ㄧ殑C鐨凙PI鐗堟湰
json
>>> import json
>>> data = {"spam" : "foo", "parrot" : 42}
>>> in_json = json.dumps(data) # Encode the data
>>> in_json'{"parrot": 42, "spam": "foo"}'>>> json.loads(in_json) # Decode into a Python object{"spam" : "foo", "parrot" : 42}
urllib 鍜寀rllib2
urllib2鍙互鐢╱rllib2.openurl涓缃甊equest鍙傛暟锛屾潵淇敼Header澶淬�傚鏋滀綘璁块棶涓�涓綉绔欙紝鎯虫洿鏀筓ser Agent锛堝彲浠ヤ吉瑁呬綘鐨勬祻瑙堝櫒锛夛紝浣犲氨瑕佺敤urllib2.
urllib鏀寔璁剧疆缂栫爜鐨勫嚱鏁帮紝urllib.urlencode,鍦ㄦā鎷熺櫥闄嗙殑鏃跺�欙紝缁忓父瑕乸ost缂栫爜涔嬪悗鐨勫弬鏁帮紝鎵�浠ヨ鎯充笉浣跨敤绗笁鏂瑰簱瀹屾垚妯℃嫙鐧诲綍锛屼綘灏遍渶瑕佷娇鐢╱rllib銆�
urllib涓�鑸拰urllib2涓�璧锋惌閰嶄娇鐢�
杩欎釜闈㈣瘯瀹樼‘瀹為棶杩�,褰撴椂绛旂殑urllib2鍙互Post鑰寀rllib涓嶅彲浠�.
urllib鎻愪緵urlencode鏂规硶鐢ㄦ潵GET鏌ヨ瀛楃涓茬殑浜х敓锛岃�寀rllib2娌℃湁銆傝繖鏄负浣晆rllib甯稿拰urllib2涓�璧蜂娇鐢ㄧ殑鍘熷洜銆�
urllib2鍙互鎺ュ彈涓�涓猂equest绫荤殑瀹炰緥鏉ヨ缃甎RL璇锋眰鐨刪eaders锛寀rllib浠呭彲浠ユ帴鍙桿RL銆傝繖鎰忓懗鐫�锛屼綘涓嶅彲浠ヤ吉瑁呬綘鐨刄ser Agent瀛楃涓茬瓑銆�
itertools
>>> import itertools>>> natuals = itertools.count(1)>>> for n in natuals:...聽 聽 print n
...123...
>>> import itertools>>> cs = itertools.cycle('ABC') # 娉ㄦ剰瀛楃涓蹭篃鏄簭鍒楃殑涓�绉�>>> for c in cs:...聽 聽 print c
...'A''B''C''A''B''C'...
>>> ns = itertools.repeat('A', 10)>>> for n in ns:...聽 聽 print n
...
鎵撳嵃10娆�'A'
functools.partial 閫氳繃鍖呰鎵嬫硶锛屽厑璁告垜浠� "閲嶆柊瀹氫箟" 鍑芥暟绛惧悕
# shutil 妯″潡
shutil.copyfile( src, dst)聽浠庢簮src澶嶅埗鍒癲st涓幓銆傚綋鐒跺墠鎻愭槸鐩爣鍦板潃鏄叿澶囧彲鍐欐潈闄愩�傛姏鍑虹殑寮傚父淇℃伅涓篒OException. 濡傛灉褰撳墠鐨刣st宸插瓨鍦ㄧ殑璇濆氨浼氳瑕嗙洊鎺�
shutil.move( src, dst)聽聽绉诲姩鏂囦欢鎴栭噸鍛藉悕
shutil.copymode( src, dst)聽鍙槸浼氬鍒跺叾鏉冮檺鍏朵粬鐨勪笢瑗挎槸涓嶄細琚鍒剁殑
shutil.copystat( src, dst)聽澶嶅埗鏉冮檺銆佹渶鍚庤闂椂闂淬�佹渶鍚庝慨鏀规椂闂�
shutil.copy( src, dst)聽聽澶嶅埗涓�涓枃浠跺埌涓�涓枃浠舵垨涓�涓洰褰�
shutil.copy2( src, dst)聽聽鍦╟opy涓婄殑鍩虹涓婂啀澶嶅埗鏂囦欢鏈�鍚庤闂椂闂翠笌淇敼鏃堕棿涔熷鍒惰繃鏉ヤ簡锛岀被浼间簬cp 鈥損鐨勪笢瑗�
shutil.copy2( src, dst)聽聽濡傛灉涓や釜浣嶇疆鐨勬枃浠剁郴缁熸槸涓�鏍风殑璇濈浉褰撲簬鏄痳ename鎿嶄綔锛屽彧鏄敼鍚嶏紱濡傛灉鏄笉鍦ㄧ浉鍚岀殑鏂囦欢绯荤粺鐨勮瘽灏辨槸鍋歮ove鎿嶄綔
shutil.copytree( olddir, newdir, True/Flase)
鎶妎lddir鎷疯礉涓�浠絥ewdir锛屽鏋滅3涓弬鏁版槸True锛屽垯澶嶅埗鐩綍鏃跺皢淇濇寔鏂囦欢澶逛笅鐨勭鍙疯繛鎺ワ紝濡傛灉绗�3涓弬鏁版槸False锛屽垯灏嗗湪澶嶅埗鐨勭洰褰曚笅鐢熸垚鐗╃悊鍓湰鏉ユ浛浠g鍙疯繛鎺�
shutil.rmtree( src )聽閫掑綊鍒犻櫎涓�涓洰褰曚互鍙婄洰褰曞唴鐨勬墍鏈夊唴瀹�
#pickle 妯″潡
python鐨刾ickle妯″潡瀹炵幇浜嗗熀鏈殑鏁版嵁搴忓垪鍜屽弽搴忓垪鍖栥�傞�氳繃pickle妯″潡鐨勫簭鍒楀寲鎿嶄綔鎴戜滑鑳藉灏嗙▼搴忎腑杩愯鐨勫璞′俊鎭繚瀛樺埌鏂囦欢涓幓锛屾案涔呭瓨鍌紱閫氳繃pickle妯″潡鐨勫弽搴忓垪鍖栨搷浣滐紝鎴戜滑鑳藉浠庢枃浠朵腑鍒涘缓涓婁竴娆$▼搴忎繚瀛樼殑瀵硅薄銆�
銆�pickle.dump(obj, file, [,protocol])
pickle.load(file)
#浣跨敤pickle妯″潡灏嗘暟鎹璞′繚瀛樺埌鏂囦欢
import pickle
data1 = {'a': [1, 2.0, 3, 4+6j],
聽 聽 聽 聽 'b': ('string', u'Unicode string'),
聽 聽 聽 聽 'c': None}
selfref_list = [1, 2, 3]
selfref_list.append(selfref_list)
output = open('data.pkl', 'wb')
# Pickle dictionary using protocol 0.
pickle.dump(data1, output)
# Pickle the list using the highest protocol available.
pickle.dump(selfref_list, output, -1)
output.close()
聽hashlib鏄秹鍙婂畨鍏ㄦ暎鍒楀拰娑堟伅鎽樿锛屾彁渚涘涓笉鍚岀殑鍔犲瘑绠楁硶鍊熷彛锛屽SHA1銆丼HA224銆丼HA256銆丼HA384銆丼HA512銆丮D5绛�
import hashlib
m = hashlib.md5()聽 #鍒涘缓hash瀵硅薄锛宮d5:(message-Digest Algorithm 5)娑堟伅鎽樿绠楁硶,寰楀嚭涓�涓�128浣嶇殑瀵嗘枃print m聽 聽 聽 聽 聽 聽 #m.update('BeginMan')#鏇存柊鍝堝笇瀵硅薄浠ュ瓧绗︿覆鍙傛暟print m.digest()聽 聽 #杩斿洖鎽樿锛屼綔涓轰簩杩涘埗鏁版嵁瀛楃涓插�紁rint m.hexdigest() #杩斿洖鍗佸叚杩涘埗鏁板瓧瀛楃涓猜� 聽 0b28251e684dfbd9102f8b6f0281c0c5print m.digest_size #16print m.block_size聽 #64
select poll epoll
2.6浠ュ悗鐨勫唴鏍稿氨鏄痚poll锛宼ornado涔熸槸epoll
select鐨勪竴涓己鐐瑰湪浜庡崟涓繘绋嬭兘澶熺洃瑙嗙殑鏂囦欢鎻忚堪绗︾殑鏁伴噺瀛樺湪鏈�澶ч檺鍒�.select()鎵�缁存姢鐨勫瓨鍌ㄥぇ閲忔枃浠舵弿杩扮鐨勬暟鎹粨鏋勶紝闅忕潃鏂囦欢鎻忚堪绗︽暟閲忕殑澧炲ぇ锛屽叾澶嶅埗鐨勫紑閿�涔熺嚎鎬у闀裤�傚悓鏃讹紝鐢变簬缃戠粶鍝嶅簲鏃堕棿鐨勫欢杩� 浣垮緱澶ч噺TCP杩炴帴澶勪簬闈炴椿璺冪姸鎬侊紝浣嗚皟鐢╯elect()浼氬鎵�鏈塻ocket杩涜涓�娆$嚎鎬ф壂鎻忥紝鎵�浠ヨ繖涔熸氮璐逛簡涓�瀹氱殑寮�閿�銆�
poll娌℃湁鏈�澶ф枃浠舵弿杩扮鏁伴噺鐨勯檺鍒躲��
poll鍜宻elect鍚屾牱瀛樺湪涓�涓己鐐瑰氨鏄紝鍖呭惈澶ч噺鏂囦欢鎻忚堪绗︾殑鏁扮粍琚暣浣撳鍒朵簬鐢ㄦ埛鎬佸拰鍐呮牳鐨勫湴鍧�绌洪棿涔嬮棿锛岃�屼笉璁鸿繖浜涙枃浠舵弿杩扮鏄惁灏辩华锛屽畠鐨勫紑閿�闅忕潃鏂囦欢鎻忚堪绗︽暟閲忕殑澧炲姞鑰岀嚎鎬у澶с��
epoll閲囩敤鍩轰簬浜嬩欢鐨勫氨缁�氱煡鏂瑰紡銆�
褰撲竴涓湇鍔″櫒闇�瑕佷笌澶氫釜瀹㈡埛绔繘琛岄�氫俊鏃讹紝鍙互浣跨敤澶氳繘绋嬫垨鑰呭绾跨▼鐨勬湇鍔″櫒锛屼篃鍙互浣跨敤select妯″潡锛屽畠鍙互瀹炵幇寮傛閫氫俊
鍩烘湰涓妔elect鏈�3涓己鐐�:
杩炴帴鏁板彈闄�
鏌ユ壘閰嶅閫熷害鎱�
鏁版嵁鐢卞唴鏍告嫹璐濆埌鐢ㄦ埛鎬�
#cookielib 妯″潡
python鍐呯疆鏈塩ookielib妯″潡鎿嶄綔cookie锛岄厤鍚坲rllib妯″潡灏卞彲浠ヤ簡寰堣交鏄撶殑鐖彇鏁版嵁銆�
鍒楄〃鎺ㄥ寮�
>>> [x * x for x in range(1, 11) if x % 2 == 0]
[4, 16, 36, 64, 100]
>>> [m + n for m in 'ABC' for n in 'XYZ']
['AX', 'AY', 'AZ', 'BX', 'BY', 'BZ', 'CX', 'CY', 'CZ']
>>> d = {'x': 'A', 'y': 'B', 'z': 'C' }>>> for k, v in d.iteritems():...聽 聽 print k, '=', v... y = B
x = A
z = C
Python鍨冨溇鍥炴敹鏈哄埗
Python GC涓昏浣跨敤寮曠敤璁℃暟锛坮eference counting锛夋潵璺熻釜鍜屽洖鏀跺瀮鍦俱�傚湪寮曠敤璁℃暟鐨勫熀纭�涓婏紝閫氳繃鈥滄爣璁�-娓呴櫎鈥濓紙mark and sweep锛夎В鍐冲鍣ㄥ璞″彲鑳戒骇鐢熺殑寰幆寮曠敤闂锛岄�氳繃鈥滃垎浠e洖鏀垛�濓紙generation collection锛変互绌洪棿鎹㈡椂闂寸殑鏂规硶鎻愰珮鍨冨溇鍥炴敹鏁堢巼銆�
1 寮曠敤璁℃暟
PyObject鏄瘡涓璞″繀鏈夌殑鍐呭锛屽叾涓璷b_refcnt灏辨槸鍋氫负寮曠敤璁℃暟銆傚綋涓�涓璞℃湁鏂扮殑寮曠敤鏃讹紝瀹冪殑ob_refcnt灏变細澧炲姞锛屽綋寮曠敤瀹冪殑瀵硅薄琚垹闄わ紝瀹冪殑ob_refcnt灏变細鍑忓皯.寮曠敤璁℃暟涓�0鏃讹紝璇ュ璞$敓鍛藉氨缁撴潫浜嗐��
浼樼偣:
绠�鍗�
瀹炴椂鎬�
缂虹偣:
缁存姢寮曠敤璁℃暟娑堣�楄祫婧�
寰幆寮曠敤
2 鏍囪-娓呴櫎鏈哄埗
鍩烘湰鎬濊矾鏄厛鎸夐渶鍒嗛厤锛岀瓑鍒版病鏈夌┖闂插唴瀛樼殑鏃跺�欎粠瀵勫瓨鍣ㄥ拰绋嬪簭鏍堜笂鐨勫紩鐢ㄥ嚭鍙戯紝閬嶅巻浠ュ璞′负鑺傜偣銆佷互寮曠敤涓鸿竟鏋勬垚鐨勫浘锛屾妸鎵�鏈夊彲浠ヨ闂埌鐨勫璞℃墦涓婃爣璁帮紝鐒跺悗娓呮壂涓�閬嶅唴瀛樼┖闂达紝鎶婃墍鏈夋病鏍囪鐨勫璞¢噴鏀俱��
3 鍒嗕唬鎶�鏈�
鍒嗕唬鍥炴敹鐨勬暣浣撴�濇兂鏄細灏嗙郴缁熶腑鐨勬墍鏈夊唴瀛樺潡鏍规嵁鍏跺瓨娲绘椂闂村垝鍒嗕负涓嶅悓鐨勯泦鍚堬紝姣忎釜闆嗗悎灏辨垚涓轰竴涓�滀唬鈥濓紝鍨冨溇鏀堕泦棰戠巼闅忕潃鈥滀唬鈥濈殑瀛樻椿鏃堕棿鐨勫澶ц�屽噺灏忥紝瀛樻椿鏃堕棿閫氬父鍒╃敤缁忚繃鍑犳鍨冨溇鍥炴敹鏉ュ害閲忋��
Python榛樿瀹氫箟浜嗕笁浠e璞¢泦鍚堬紝绱㈠紩鏁拌秺澶э紝瀵硅薄瀛樻椿鏃堕棿瓒婇暱銆�
涓句緥锛�
褰撴煇浜涘唴瀛樺潡M缁忚繃浜�3娆″瀮鍦炬敹闆嗙殑娓呮礂涔嬪悗杩樺瓨娲绘椂锛屾垜浠氨灏嗗唴瀛樺潡M鍒掑埌涓�涓泦鍚圓涓幓锛岃�屾柊鍒嗛厤鐨勫唴瀛橀兘鍒掑垎鍒伴泦鍚圔涓幓銆傚綋鍨冨溇鏀堕泦寮�濮嬪伐浣滄椂锛屽ぇ澶氭暟鎯呭喌閮藉彧瀵归泦鍚圔杩涜鍨冨溇鍥炴敹锛岃�屽闆嗗悎A杩涜鍨冨溇鍥炴敹瑕侀殧鐩稿綋闀夸竴娈垫椂闂村悗鎵嶈繘琛岋紝杩欏氨浣垮緱鍨冨溇鏀堕泦鏈哄埗闇�瑕佸鐞嗙殑鍐呭瓨灏戜簡锛屾晥鐜囪嚜鐒跺氨鎻愰珮浜嗐�傚湪杩欎釜杩囩▼涓紝闆嗗悎B涓殑鏌愪簺鍐呭瓨鍧楃敱浜庡瓨娲绘椂闂撮暱鑰屼細琚浆绉诲埌闆嗗悎A涓紝褰撶劧锛岄泦鍚圓涓疄闄呬笂涔熷瓨鍦ㄤ竴浜涘瀮鍦撅紝杩欎簺鍨冨溇鐨勫洖鏀朵細鍥犱负杩欑鍒嗕唬鐨勬満鍒惰�岃寤惰繜銆�
杩唬鍣ㄥ拰鐢熸垚鍣�
涓嶉�傜敤杩唬鍣�
def fab(max):
聽 聽 L = []
聽 聽 n, a, b = 0, 0, 1
聽 聽 while n < max:
聽 聽 聽 聽 L.append(b)
聽 聽 聽 聽 a, b = b, a + b
聽 聽 聽 聽 n = n + 1
聽 聽 return L
class Fab(object):
聽 聽 def __init__(self, max):
聽 聽 聽 聽 self.max = max
聽 聽 聽 聽 self.n, self.a, self.b = 0, 0, 1
聽 聽 def __iter__(self):
聽 聽 聽 聽 return self
聽 聽 def next(self):
聽 聽 聽 聽 if self.n < self.max:
聽 聽 聽 聽 聽 聽 r = self.b
聽 聽 聽 聽 聽 聽 self.a, self.b = self.b, self.a + self.b
聽 聽 聽 聽 聽 聽 self.n = self.n + 1
聽 聽 聽 聽 聽 聽 return r
聽 聽 聽 聽 raise StopIteration()
鐢熸垚鍣紙yield锛夋棦鍙互淇濇寔浠g爜1鐨勭畝娲佹�э紝鍙堝彲浠ヤ繚鎸佷唬鐮�3鐨勬晥鏋�
def fab(max):
聽 聽 n, a, b = 0, 0, 1
聽 聽 while n < max:
聽 聽 聽 聽 yield b
聽 聽 聽 聽 a, b = b, a + b
聽 聽 聽 聽 n = n + 1
Cookie鍜孲ession
CookieSession
鍌ㄥ瓨浣嶇疆瀹㈡埛绔湇鍔″櫒绔�
鐩殑璺熻釜浼氳瘽锛屼篃鍙互淇濆瓨鐢ㄦ埛鍋忓ソ璁剧疆鎴栬�呬繚瀛樼敤鎴峰悕瀵嗙爜绛夎窡韪細璇�
瀹夊叏鎬т笉瀹夊叏瀹夊叏
session鎶�鏈槸瑕佷娇鐢ㄥ埌cookie鐨勶紝涔嬫墍浠ュ嚭鐜皊ession鎶�鏈紝涓昏鏄负浜嗗畨鍏ㄣ��
XSRF鍜孹SS
CSRF(Cross-site request forgery)璺ㄧ珯璇锋眰浼��
XSS(Cross Site Scripting)璺ㄧ珯鑴氭湰鏀诲嚮
CSRF閲嶇偣鍦ㄨ姹�,XSS閲嶇偣鍦ㄨ剼鏈�
nginx
鎶楀苟鍙戯紝nginx 澶勭悊璇锋眰鏄紓姝ラ潪闃诲鐨勶紝鏀寔鏇村鐨勫苟鍙戣繛鎺ワ紝鑰宎pache 鍒欐槸闃诲鍨嬬殑锛屽湪楂樺苟鍙戜笅nginx 鑳戒繚鎸佷綆璧勬簮浣庢秷鑰楅珮鎬ц兘
restful
锛�1锛夋瘡涓�涓猆RI浠h〃涓�绉嶈祫婧愶紱
銆�銆�锛�2锛夊鎴风鍜屾湇鍔″櫒涔嬮棿锛屼紶閫掕繖绉嶈祫婧愮殑鏌愮琛ㄧ幇灞傦紱
銆�銆�锛�3锛夊鎴风閫氳繃鍥涗釜HTTP鍔ㄨ瘝锛屽鏈嶅姟鍣ㄧ璧勬簮杩涜鎿嶄綔锛屽疄鐜�"琛ㄧ幇灞傜姸鎬佽浆鍖�"銆�
Python鑷渷
杩欎釜涔熸槸python褰倣鐨勭壒鎬�.
鑷渷灏辨槸闈㈠悜瀵硅薄鐨勮瑷�鎵�鍐欑殑绋嬪簭鍦ㄨ繍琛屾椂,鎵�鑳界煡閬撳璞$殑绫诲瀷.绠�鍗曚竴鍙ュ氨鏄繍琛屾椂鑳藉鑾峰緱瀵硅薄鐨勭被鍨�.姣斿type(),dir(),getattr(),hasattr(),isinstance().
瀛楀吀鎺ㄥ寮�
L = [1,2,3,4,5,6,7,8,9]
瑕佺敓鎴愪笅闈㈣繖鏍风殑瀛楀吀锛�
{1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60, 7: 70, 8: 80, 9: 90}
浠ュ墠闇�瑕佽繖鏍凤細
dict([(v, v*10) for v in L])
鐜板湪鍙互鐩存帴杩欐牱锛�
{v: v*10 for v in L}
Python鐨勫嚱鏁板弬鏁颁紶閫�
鐪嬩袱涓緥瀛�:
Python
1
2
3
4
5
a = 1
def fun(a):
a = 2
fun(a)
print a # 1
Python
1
2
3
4
5
a = []
def fun(a):
a.append(1)
fun(a)
print a # [1]
鎵�鏈夌殑鍙橀噺閮藉彲浠ョ悊瑙f槸鍐呭瓨涓竴涓璞$殑鈥滃紩鐢ㄢ�濓紝鎴栬�咃紝涔熷彲浠ョ湅浼糲涓璿oid*鐨勬劅瑙夈��
杩欓噷璁颁綇鐨勬槸绫诲瀷鏄睘浜庡璞$殑锛岃�屼笉鏄彉閲忋�傝�屽璞℃湁涓ょ,鈥滃彲鏇存敼鈥濓紙mutable锛変笌鈥滀笉鍙洿鏀光�濓紙immutable锛夊璞°�傚湪python涓紝strings, tuples, 鍜宯umbers鏄笉鍙洿鏀圭殑瀵硅薄锛岃�宭ist,dict绛夊垯鏄彲浠ヤ慨鏀圭殑瀵硅薄銆�(杩欏氨鏄繖涓棶棰樼殑閲嶇偣)
褰撲竴涓紩鐢ㄤ紶閫掔粰鍑芥暟鐨勬椂鍊�,鍑芥暟鑷姩澶嶅埗涓�浠藉紩鐢�,杩欎釜鍑芥暟閲岀殑寮曠敤鍜屽杈圭殑寮曠敤娌℃湁鍗婃瘺鍏崇郴浜�.鎵�浠ョ涓�涓緥瀛愰噷鍑芥暟鎶婂紩鐢ㄦ寚鍚戜簡涓�涓笉鍙彉瀵硅薄,褰撳嚱鏁拌繑鍥炵殑鏃跺��,澶栭潰鐨勫紩鐢ㄦ病鍗婃瘺鎰熻.鑰岀浜屼釜渚嬪瓙灏变笉涓�鏍蜂簡,鍑芥暟鍐呯殑寮曠敤鎸囧悜鐨勬槸鍙彉瀵硅薄,瀵瑰畠鐨勬搷浣滃氨鍜屽畾浣嶄簡鎸囬拡鍦板潃涓�鏍�,鍦ㄥ唴瀛橀噷杩涜淇敼.
杩涚▼鍜岀嚎绋�
绾跨▼鍒囨崲
璁$畻瀵嗛泦鍨嬄� 涓嶉�傚悎鐢╬ython
IO瀵嗛泦鍨嬄� 缃戠粶锛岀鐩橈紝web搴旂敤锛岀摱棰堜笉鍦–PU
鎿嶄綔绯荤粺鎻愪緵寮傛IO鐨勬敮鎸侊紝绉颁负浜嬩欢椹卞姩妯″瀷
Nginx灏辨槸鏀寔寮傛IO鐨刉eb鏈嶅姟鍣紝瀹冨湪鍗曟牳CPU涓婇噰鐢ㄥ崟杩涚▼妯″瀷灏卞彲浠ラ珮鏁堝湴鏀寔澶氫换鍔�
瀵瑰簲鍒癙ython璇█锛屽崟杩涚▼鐨勫紓姝ョ紪绋嬫ā鍨嬬О涓哄崗绋嬶紝鏈変簡鍗忕▼鐨勬敮鎸侊紝灏卞彲浠ュ熀浜庝簨浠堕┍鍔ㄧ紪鍐欓珮鏁堢殑澶氫换鍔$▼搴�
搴忓垪鍖�
Python璇█鐗瑰畾鐨勫簭鍒楀寲妯″潡鏄痯ickle锛屼絾濡傛灉瑕佹妸搴忓垪鍖栨悶寰楁洿閫氱敤銆佹洿绗﹀悎Web鏍囧噯锛屽氨鍙互浣跨敤json妯″潡銆�
json妯″潡鐨刣umps()鍜宭oads()鍑芥暟鏄畾涔夊緱闈炲父濂界殑鎺ュ彛鐨勫吀鑼冦��
缁ф壙
class A(object):
聽 聽 def go(self):
聽 聽 聽 聽 print "go A go!"
聽 聽 def stop(self):
聽 聽 聽 聽 print "stop A stop!"
聽 聽 def pause(self):
聽 聽 聽 聽 raise Exception("Not Implemented")
class B(A):
聽 聽 def go(self):
聽 聽 聽 聽 super(B, self).go()
聽 聽 聽 聽 print "go B go!"
python璇█浼樺娍
瑙i噴鍨嬶細涓嶉渶瑕佺紪璇懧� 鍔ㄦ�侊細澹版槑鍙橀噺涓嶉渶瑕佽鏄庡彉閲忕殑绫诲瀷锛屼笓娉ㄤ簬绠楁硶鍜屾暟鎹粨鏋勭殑璁捐锛屼笉鐢ㄥ鐞嗗簳灞傜粏鑺傦紝鑳舵按璇█
杩愯閫熷害鎱�
閫掑綊绠楁硶
def print_directory_contents(sPath):
聽 聽 import os
聽 聽 for sChild in os.listdir(sPath):
聽 聽 聽 聽 sChildPath = os.path.join(sPath,sChild)
聽 聽 聽 聽 if os.path.isdir(sChildPath):
聽 聽 聽 聽 聽 聽 print_directory_contents(sChildPath)
聽 聽 聽 聽 else:
聽 聽 聽 聽 聽 聽 print sChildPath
print_directory_contents('C:/Users/F1316196/PycharmProjects/untitled/')
鏃у垪琛ㄥ拰鏂板垪琛ㄤ紶鍙傛暟
def f(x,l=[]):
聽 聽 for i in range(x):
聽 聽 聽 聽 l.append(i*i)
聽 聽 print l
f(2)
f(3,[3,2,1])
f(3)
[0, 1]
[3, 2, 1, 0, 1, 4]
[0, 1, 0, 1, 4]
鍚勭璇█閮界敤杩囷紝鎵嶄細瀵瑰悇绉嶆蹇垫湁鏇存繁鍒荤殑鐞嗚В銆�
nodejs聽 express聽 瀹炵幇restful web service聽 鍗宠〃杩版�х姸鎬佷紶閫掞紙鑻辨枃锛歊epresentational State Transfer锛岀畝绉癛EST聽
浠ヤ笅涓� REST 鍩烘湰鏋舵瀯鐨勫洓涓柟娉曪細
GET聽- 鐢ㄤ簬鑾峰彇鏁版嵁銆�
PUT聽- 鐢ㄤ簬娣诲姞鏁版嵁銆�
DELETE聽- 鐢ㄤ簬鍒犻櫎鏁版嵁銆�
POST聽- 鐢ㄤ簬鏇存柊鎴栨坊鍔犳暟鎹��
缁忓巻锛氳幏鍙栫敤鎴峰垪琛紝娣诲姞鍒犻櫎鐢ㄦ埛 锛泈ebui 11.5 html5 redfish鍗忚锛宲ostman锛屽湪system锛宑hassis锛宮anager鏂归潰娴嬭瘯銆�
寰俊寮�鍙�
寰俊鍏紬鍙� 锛寀rl锛宼oken
index.wsgi聽 鐩稿綋浜巚iews.py
get杩囨潵鐨勮繘琛岄獙璇�
post杩囨潵鐨勬暟鎹繘琛孹ML瑙f瀽锛岃幏寰楃敤鎴锋墍杈撳叆鐨勫唴瀹�
memcached
pylibmc聽 random聽 set get random.choice
$def聽with聽(toUser,fromUser,createTime,content)
$createTime
SSH 妗嗘灦鐨勭悊瑙�
maven ,ant,web.xml,spirng-mvc-servlet.xml
AOP聽 IOC 鎺у埗鍙嶈浆锛屼緷璧栨敞鍏�
@controller聽 @requestMapping
xml鐗堟湰锛屾敞瑙g増鏈繘琛屾帶鍒�
SpringAOP 鏄潰鍚戞柟闈㈢紪绋嬶紝瀹炵幇浜嬪姟澶勭悊銆佹棩蹇楁湇鍔$瓑涓庝笟鍔℃棤鍏崇殑绯荤粺鏈嶅姟锛屽疄鐜版彃浠跺紡缂栫▼銆�
Spring鐨処oC鏉ュ疄鐜扮粍浠朵箣闂寸殑渚濊禆鍏崇郴娉ㄥ叆
Struts鍦ㄩ」鐩腑涓昏璐熻矗瑙嗗浘灞傘�佹帶鍒跺眰锛屽湪瑙嗗浘灞傛彁渚涗簡澶ч噺鐨勬爣绛惧簱锛屾彁楂樿鍥惧眰鐨勫紑鍙戦�熷害銆傚湪鎺у埗灞備娇鐢ㄤ腑澶帶鍒跺櫒锛圓ctionsupport锛夊拰閰嶇疆鏂囦欢(struts.xml)锛屽疄鐜版嫤鎴敤鎴疯姹傘�佸皝瑁呰姹傚弬鏁板強椤甸潰瀵艰埅銆�
鏀规暟鎹簱涓嶉渶瑕佹洿鏀逛唬鐮侊紝鍥犱负Hibernate浼氭牴鎹暟鎹簱鏂硅█鏉ョ敓鎴愬搴旂殑SQL璇彞锛�2銆佹槸瀵笿DBC鐨勮交閲忕骇灏佽锛岀畝鍖栨寔涔呭眰鐨勪唬鐮侊紝鎻愰珮寮�鍙戦�熷害銆�
AngularJS聽
ng-app聽鎸囦护鍛婅瘔 AngularJS锛�
ng-model聽鎸囦护鎶婅緭鍏ュ煙鐨勫�肩粦瀹氬埌搴旂敤绋嬪簭鍙橀噺聽name銆�
ng-bind聽鎸囦护鎶婂簲鐢ㄧ▼搴忓彉閲� name 缁戝畾鍒版煇涓钀界殑 innerHTML銆�
鎶婂悗鍙板疄鐜扮Щ鍔ㄥ埌浜嗗墠绔�
Html5 鏂扮壒鐐�
Audio & Video:聽鍙互宓屽叆鎮ㄧ殑缃戦〉涓婄殑闊抽鎴栬棰戯紝鑰屼笉璇夎绗笁鏂规彃浠�.
Drag and drop:聽浠庝竴涓綅缃埌鍙︿竴涓綅缃殑鍚屼竴缃戦〉涓婃嫋鏀鹃」鐩�.
WebSocket :聽涓嬩竴浠eb搴旂敤绋嬪簭鐨勫弻鍚戦�氳鎶�鏈��
鏂扮殑璇箟鍏冪礌:聽瀹冧滑濡偮�, 鍜屄�.
nodejs
goole V8
鍥炶皟鍑芥暟 express 浜嬩欢椹卞姩
浜嬩欢椹卞姩绋嬪簭
Node.js 浣跨敤浜嬩欢椹卞姩妯″瀷锛屽綋web server鎺ユ敹鍒拌姹傦紝灏辨妸瀹冨叧闂劧鍚庤繘琛屽鐞嗭紝鐒跺悗鍘绘湇鍔′笅涓�涓獁eb璇锋眰銆�
褰撹繖涓姹傚畬鎴愶紝瀹冭鏀惧洖澶勭悊闃熷垪锛屽綋鍒拌揪闃熷垪寮�澶达紝杩欎釜缁撴灉琚繑鍥炵粰鐢ㄦ埛銆�
杩欎釜妯″瀷闈炲父楂樻晥鍙墿灞曟�ч潪甯稿己锛屽洜涓簑ebserver涓�鐩存帴鍙楄姹傝�屼笉绛夊緟浠讳綍璇诲啓鎿嶄綔銆傦紙杩欎篃琚О涔嬩负闈為樆濉炲紡IO鎴栬�呬簨浠堕┍鍔↖O锛�
鍦ㄤ簨浠堕┍鍔ㄦā鍨嬩腑锛屼細鐢熸垚涓�涓富寰幆鏉ョ洃鍚簨浠讹紝褰撴娴嬪埌浜嬩欢鏃惰Е鍙戝洖璋冨嚱鏁般��
鍓嶇
jquery閫夋嫨鍣紝浜嬩欢鏂规硶聽 聽 jquery ajax聽 load锛実et锛宲ost
jqueryUI聽 鏃ユ湡閫夋嫨鍣紝灏忛儴浠� widget
jquery ui 鏄痡query寮�鍙戝洟闃� 寮�鍙戯紝閫傜敤浜庣綉绔欏紡鐨勯〉闈€��
jquery easyui 鏄涓夋柟鍩轰簬jquery寮�鍙戯紝閫傜敤浜庡簲鐢ㄧ▼搴忓紡鐨勯〉闈€��
涓よ�呯殑鏂规硶璋冪敤涔熺暐鏈変笉鍚岋細
jquery ui 鏄細
$("#divTabs").tabs("remove" , index);
jquery easyui 鏄細
$("#divTabs").tabs("close" , title);
bootstrap鍙鍖栫粍浠�
鍙嶅皠锛堣嚜鐪侊級
python鐨勫弽灏勶紝瀹冪殑鏍稿績鏈川鍏跺疄灏辨槸鍒╃敤瀛楃涓茬殑褰㈠紡鍘诲璞★紙妯″潡锛変腑鎿嶄綔锛堟煡鎵�/鑾峰彇/鍒犻櫎/娣诲姞锛夋垚鍛橈紝涓�绉嶅熀浜庡瓧绗︿覆鐨勪簨浠堕┍鍔紒
import commons
def run():
聽 聽 inp = input("璇疯緭鍏ユ偍鎯宠闂〉闈㈢殑url锛� ").strip()
聽 聽 func = getattr(commons, inp)
聽 聽 func()
if __name__ == '__main__':
聽 聽 run()
python鐨勫洓涓噸瑕佸唴缃嚱鏁帮細getattr銆乭asattr銆乨elattr鍜宻etattr杈冧负鍏ㄩ潰鐨勫疄鐜颁簡鍩轰簬瀛楃涓茬殑鍙嶅皠鏈哄埗銆備粬浠兘鏄鍐呭瓨鍐呯殑妯″潡杩涜鎿嶄綔锛屽苟涓嶄細瀵规簮鏂囦欢杩涜淇敼銆�
澶氳繘绋� 澶氱嚎绋�
gevent鍗忕▼
from gevent import monkey; monkey.patch_socket()import geventdef f(n):
聽 聽 for i in range(n):
聽 聽 聽 聽 print gevent.getcurrent(), i
g1 = gevent.spawn(f, 5)
g2 = gevent.spawn(f, 5)
g3 = gevent.spawn(f, 5)
g1.join()
g2.join()
g3.join()
绠�杩癙ython鐨勪綔鐢ㄥ煙浠ュ強Python鎼滅储鍙橀噺鐨勯『搴�
Python浣滅敤鍩熺畝鍗曡灏辨槸涓�涓彉閲忕殑鍛藉悕绌洪棿銆備唬鐮佷腑鍙橀噺琚祴鍊肩殑浣嶇疆锛屽氨鍐冲畾浜嗗摢浜涜寖鍥寸殑瀵硅薄鍙互璁块棶杩欎釜鍙橀噺锛岃繖涓寖鍥村氨鏄彉閲忕殑浣滅敤鍩熴�傚湪Python涓紝鍙湁妯″潡锛坢odule锛夛紝绫伙紙class锛変互鍙婂嚱鏁帮紙def銆乴ambda锛夋墠浼氬紩鍏ユ柊鐨勪綔鐢ㄥ煙銆侾ython鐨勫彉閲忓悕瑙f瀽鏈哄埗涔熺О涓� LEGB 娉曞垯锛氭湰鍦颁綔鐢ㄥ煙锛圠ocal锛夆啋褰撳墠浣滅敤鍩熻宓屽叆鐨勬湰鍦颁綔鐢ㄥ煙锛圗nclosing locals锛夆啋鍏ㄥ眬/妯″潡浣滅敤鍩燂紙Global锛夆啋鍐呯疆浣滅敤鍩燂紙Built-in锛�
澶氱嚎绋嬩唬鐮�
Lock銆丷lock绫�
Condition绫�
鍙互璁や负锛岄櫎浜哃ock甯︽湁鐨勯攣瀹氭睜澶栵紝Condition杩樺寘鍚竴涓瓑寰呮睜锛屾睜涓殑绾跨▼澶勪簬绛夊緟闃诲鐘舵�侊紝鐩村埌鍙︿竴涓嚎绋嬭皟鐢╪otify()/notifyAll()閫氱煡锛涘緱鍒伴�氱煡鍚庣嚎绋嬭繘鍏ラ攣瀹氭睜绛夊緟閿佸畾銆�
Event绫�
Event鍏跺疄灏辨槸涓�涓畝鍖栫増鐨� Condition銆侲vent娌℃湁閿侊紝鏃犳硶浣跨嚎绋嬭繘鍏ュ悓姝ラ樆濉炵姸鎬併��
timer绫�
Timer锛堝畾鏃跺櫒锛夋槸Thread鐨勬淳鐢熺被锛岀敤浜庡湪鎸囧畾鏃堕棿鍚庤皟鐢ㄤ竴涓柟娉曘��
Semaphore
Thread绫�
isAlive(): 杩斿洖绾跨▼鏄惁鍦ㄨ繍琛屻�傛鍦ㄨ繍琛屾寚鍚姩鍚庛�佺粓姝㈠墠銆偮�
銆�銆�get/setName(name): 鑾峰彇/璁剧疆绾跨▼鍚嶃�偮�
銆�銆�start(): 聽绾跨▼鍑嗗灏辩华锛岀瓑寰匔PU璋冨害
銆�銆�is/setDaemon(bool): 鑾峰彇/璁剧疆鏄悗鍙扮嚎绋嬶紙榛樿鍓嶅彴绾跨▼锛團alse锛夛級銆傦紙鍦╯tart涔嬪墠璁剧疆锛�
銆�銆�銆�銆�濡傛灉鏄悗鍙扮嚎绋嬶紝涓荤嚎绋嬫墽琛岃繃绋嬩腑锛屽悗鍙扮嚎绋嬩篃鍦ㄨ繘琛岋紝涓荤嚎绋嬫墽琛屽畬姣曞悗锛屽悗鍙扮嚎绋嬩笉璁烘垚鍔熶笌鍚︼紝涓荤嚎绋嬪拰鍚庡彴绾跨▼鍧囧仠姝�
聽 聽 聽 聽銆�銆�濡傛灉鏄墠鍙扮嚎绋嬶紝涓荤嚎绋嬫墽琛岃繃绋嬩腑锛屽墠鍙扮嚎绋嬩篃鍦ㄨ繘琛岋紝涓荤嚎绋嬫墽琛屽畬姣曞悗锛岀瓑寰呭墠鍙扮嚎绋嬩篃鎵ц瀹屾垚鍚庯紝绋嬪簭鍋滄
銆�銆�start(): 鍚姩绾跨▼銆偮�
銆�銆�join([timeout]): 闃诲褰撳墠涓婁笅鏂囩幆澧冪殑绾跨▼锛岀洿鍒拌皟鐢ㄦ鏂规硶鐨勭嚎绋嬬粓姝㈡垨鍒拌揪鎸囧畾鐨則imeout锛堝彲閫夊弬鏁帮級銆�
django闇�瑕佸畨瑁卭penssl锛宼wisted搴�
git
鎴戜滑浣跨敤聽git clone聽浠庣幇鏈� Git 浠撳簱涓嫹璐濋」鐩紙绫讳技聽svn checkout锛夈��
姣忎釜寮�鍙戜汉鍛樹粠涓績鐗堟湰搴�/鏈嶅姟鍣ㄤ笂chect out浠g爜鍚庝細鍦ㄨ嚜宸辩殑鏈哄櫒涓婂厠闅嗕竴涓嚜宸辩殑鐗堟湰搴撱�傚彲浠ヨ繖鏍疯锛屽鏋滀綘琚洶鍦ㄤ竴涓笉鑳借繛鎺ョ綉缁滅殑鍦版柟鏃讹紝灏卞儚鍦ㄩ鏈轰笂锛屽湴涓嬪锛岀數姊噷绛夛紝浣犱粛鐒惰兘澶熸彁浜ゆ枃浠讹紝鏌ョ湅鍘嗗彶鐗堟湰璁板綍锛屽垱寤洪」鐩垎鏀紝绛夈�傚涓�浜涗汉鏉ヨ锛岃繖濂藉儚娌″澶х敤澶勶紝浣嗗綋浣犵獊鐒堕亣鍒版病鏈夌綉缁滅殑鐜鏃讹紝杩欎釜灏嗚В鍐充綘鐨勫ぇ楹荤儲銆�
GIT鎶婂唴瀹规寜鍏冩暟鎹柟寮忓瓨鍌紝鑰孲VN鏄寜鏂囦欢锛�
python妗嗘灦姣旇緝
flask聽 聽 锛�
url鏄犲皠
@app.route('/login', methods = ['GET', 'POST'])
tornado锛�
寮傛闈為樆濉濱O
webpy锛�
瀹规槗鐞嗚В锛屽皬宸х伒娲�
鍐欒繃鐨刾ython鑴氭湰
fru淇℃伅鑾峰彇锛屾暣鐞嗘垚json鏍煎紡聽 json dumps loads
寰俊鍙仿� webpy聽 mysql聽 memcached
svn澶囦唤聽 sched瀹氭椂浠诲姟
MEI聽 platform锛宻ubprocess锛�
diag聽 閬嶅巻瑙f瀽xml
pyqt
socket浼犳枃浠讹紝瀵规椂
瑁呴グ鍣ㄨ褰曟棩蹇楋紝logging妯″潡
psuti 鏌ョ湅cpu memory鐘舵��
os.kill 鏉�姝昏繘绋�
鏁版嵁缁撴瀯
Python涓父瑙佺殑鏁版嵁缁撴瀯鍙互缁熺О涓哄鍣紙container锛夈�傝�屽簭鍒楋紙濡傚垪琛ㄥ拰鍏冪粍锛夈�佹槧灏勶紙濡傚瓧鍏革級浠ュ強闆嗗悎锛坰et锛夋槸涓夌被涓昏鐨勫鍣ㄣ��
Python涓湁6绉嶅唴寤虹殑搴忓垪銆傚叾涓垪琛ㄥ拰鍏冪粍鏄渶甯歌鐨勭被鍨嬨�傚叾浠栧寘鎷瓧绗︿覆銆乁nicode瀛楃涓层�乥uffer瀵硅薄鍜寈range瀵硅薄
绠楁硶
鍐掓场鎺掑簭娉�
array = [1,7,2,3,6,5,4]
def bubble(array):
聽 聽 for i in range(len(array)):
聽 聽 聽 聽 for j in range(i):
聽 聽 聽 聽 聽 聽 if array[j] > array[i]:
聽 聽 聽 聽 聽 聽 聽 聽 array[j], array[i] = array[i], array[j]
聽 聽 print array
聽 聽 return array
bubble(array)
bruins搴曞眰寮�鍙�
memmap锛�
ioremap鍐欏瓧绗﹁澶囬┍鍔� ioctrl
linux shell
鍑芥暟浼犲弬鏁�$聽 聽 python涔熸湁except妯″潡
璐磋繎linux鍛戒护 锛屄� expect 锛� 澶氱嚎绋� 锛� 浠g爜鍧梩ee 閲嶅畾鍚戯紝curl锛実rep锛宎wk
linux
vim 锛屾枃浠剁郴缁熸墦trap锛宻amba锛岃仈绯绘祴璇昫iag锛岀紪璇戞垚鍔ㄦ�侀潤鎬佸簱.a,.so[vesta]
娴忚鍣ㄥ吋瀹�
margin锛宲adding锛宒iv
html
select锛宱ption锛寀l锛宭i锛宖orm
鍒嗗竷寮忕悊瑙�
map/reduce
git
聽Hadoop鏄竴涓垎甯冨紡绯荤粺鍩虹妗嗘灦锛屽熀浜庤繖涓鏋跺紑鍙戝垎甯冨紡搴旂敤绋嬪簭锛屽埄鐢ㄩ泦缇ょ殑楂橀�熻繍绠楀拰瀛樺偍鐨勫▉鍔涖�傜被浼间簬锛屽熀浜嶯VIDIA 鐨� CUDA骞惰鏋舵瀯寮�鍙戝苟琛岀▼搴忥紝鍙戞尌GPU鐨勫苟琛岃绠楄兘鍔涖��
聽 聽 聽HDFS鏄疕adoop鐨勬枃浠剁郴缁熴�傚熀浜嶩DFS锛屼綘鍙互瀵规枃浠惰繘琛屾搷浣滐紝渚嬪鏂板缓锛屽垹闄わ紝缂栬緫锛岄噸鍛藉悕绛夈��
聽 聽 聽Hbase: 鍩轰簬Hadoop鏋舵瀯鐨勬暟鎹簱绯荤粺銆備笉鏄叧绯诲瀷鏁版嵁搴擄紝鍩轰簬鍒楃殑妯″紡銆�
jsp鍜宻ervlet
jsp缁忕紪璇戝悗灏卞彉鎴愪簡Servlet.(JSP鐨勬湰璐ㄥ氨鏄疭ervlet锛孞VM鍙兘璇嗗埆java鐨勭被锛屼笉鑳借瘑鍒獼SP鐨勪唬鐮�,Web瀹瑰櫒灏咼SP鐨勪唬鐮佺紪璇戞垚JVM鑳藉璇嗗埆鐨刯ava绫�)
JSP鐨勬儏鍐垫槸Java鍜孒TML鍙互缁勫悎鎴愪竴涓墿灞曞悕涓�.jsp鐨勬枃浠躲�侸SP渚ч噸浜庤鍥撅紝Servlet涓昏鐢ㄤ簬鎺у埗閫昏緫銆�
SQL
sql娉ㄥ叆
mongodb鍜孯edis
MongoDB鏇寸被浼�MySQL锛屾敮鎸佸瓧娈电储寮曘�佹父鏍囨搷浣滐紝鍏朵紭鍔垮湪浜庢煡璇㈠姛鑳芥瘮杈冨己澶э紝鎿呴暱鏌ヨJSON鏁版嵁锛岃兘瀛樺偍娴烽噺鏁版嵁锛屼絾鏄笉鏀寔浜嬪姟銆�
Mysql鍦�澶ф暟鎹�閲忔椂鏁堢巼鏄捐憲涓嬮檷锛孧ongoDB鏇村鏃跺�欎綔涓哄叧绯�鏁版嵁搴�鐨勪竴绉嶆浛浠c��
鍐呭瓨绠$悊鏈哄埗
Redis鏁版嵁鍏ㄩ儴瀛樺湪鍐呭瓨锛屽畾鏈熷啓鍏ョ鐩橈紝褰撳唴瀛樹笉澶熸椂锛屽彲浠ラ�夋嫨鎸囧畾鐨凩RU绠楁硶鍒犻櫎鏁版嵁銆�
MongoDB鏁版嵁瀛樺湪鍐呭瓨锛岀敱Linux绯荤粺mmap瀹炵幇锛屽綋鍐呭瓨涓嶅鏃讹紝鍙皢鐑偣鏁版嵁鏀惧叆鍐呭瓨锛屽叾浠栨暟鎹瓨鍦ㄧ鐩樸��
鏀寔鐨勬暟鎹粨鏋�
Redis鏀寔鐨�鏁版嵁缁撴瀯涓板瘜锛屽寘鎷琱ash銆乻et銆乴ist绛夈��
MongoDB鏁版嵁缁撴瀯姣旇緝鍗曚竴锛屼絾鏄敮鎸佷赴瀵岀殑鏁版嵁琛ㄨ揪锛岀储寮曪紝鏈�绫讳技鍏崇郴鍨嬫暟鎹簱锛屾敮鎸佺殑鏌ヨ璇█闈炲父涓板瘜銆�
mongodb
SQL鏈/姒傚康MongoDB鏈/姒傚康瑙i噴/璇存槑
databasedatabase鏁版嵁搴�
tablecollection鏁版嵁搴撹〃/闆嗗悎
rowdocument鏁版嵁璁板綍琛�/鏂囨。
columnfield鏁版嵁瀛楁/鍩�
indexindex绱㈠紩
table joins琛ㄨ繛鎺�,MongoDB涓嶆敮鎸�
primary keyprimary key涓婚敭,MongoDB鑷姩灏哶id瀛楁璁剧疆涓轰富閿�
iBATIS鎻愪緵鐨勬寔涔呭眰妗嗘灦鍖呮嫭SQL Maps鍜孌ata Access Objects锛圖AO锛�
python浼樺娍鍜岀壒鐐�
澶氶噸缁ф壙
鍒囩墖锛岃凯浠o紝鍒楄〃鐢熸垚寮忥紝鐢熸垚鍣紝鍑芥暟寮忕紪绋嬶紝鍖垮悕鍑芥暟锛岃楗板櫒锛屽亸鍑芥暟
__slots__
Python 鏄竴闂ㄥ姩鎬佽瑷�锛屽彲浠ュ湪杩愯杩囩▼涓紝淇敼瀵硅薄鐨勫睘鎬у拰澧炲垹鏂规硶銆備换浣曠被鐨勫疄渚嬪璞″寘鍚竴涓瓧鍏竉_dict__, Python閫氳繃杩欎釜瀛楀吀灏嗕换鎰忓睘鎬х粦瀹氬埌瀵硅薄涓娿�傛湁鏃跺�欐垜浠彧鎯充娇鐢ㄥ浐瀹氱殑瀵硅薄锛岃�屼笉鎯充换鎰忕粦瀹氬璞★紝杩欐椂鍊欐垜浠彲浠ュ畾涔変竴涓睘鎬у悕绉伴泦鍚堬紝鍙湁鍦ㄨ繖涓泦鍚堥噷鐨勫悕绉版墠鍙互缁戝畾銆俖_slots__灏辨槸瀹屾垚杩欎釜鍔熻兘鐨勩��