1.函數傳參時使用當前實參的引用,仍是從新建立的值?python
答:使用當時實參的引用json
2.Python的什麼爲做用域?app
A.縮進的代碼塊 B.函數ide
答:B函數
3.簡述深淺拷貝的原理?ui
答:google
4.簡述sys.path的做用以及模塊命名注意事項加密
BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))spa
https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_style_rules/#id163d
5.簡述re模塊中match、search以及findall方法的特色
1*2+3*4+5*6+7*8...+99*100
7.Python中兩種序列化json和pickle的區別
8.
1 def encode(func): 2 def wrapper(*args, **kws): 3 print('encode') 4 func(*args, **kws) 5 return wrapper 6 7 8 @encode 9 def sendMsg(text): 10 print(text) 11 12 if __name__ == '__main__': 13 sendMsg('hello world')
1 def encode(type): 2 def decorator(func): 3 def wrapper(*args, **kws): 4 print('use %d encode' % type) 5 func(*args, **kws) 6 return wrapper 7 return decorator 8 9 10 @encode(1) 11 def sendMsg(text): 12 print(text) 13 14 if __name__ == '__main__': 15 sendMsg('hello world')
首先encode內部有兩層函數定義,是一個高階函數,decorator的定義就是要返回的裝飾器函數,encode函數以sendMsg函數爲參數,在內部封裝一個新函數返回,該函數添加相應的預處理方法encode,能夠繼續二次調用。(前者)
若是有新的要求,即encode函數自身有參數,一個整形type來表示使用何種加密方法進行加密,這個時候就要修改上述寫法,在encode中加一層函數。(後者)