以下10個(gè)練手項(xiàng)目均摘錄自一本尚未出版的 Python 神書《500 Lines or Less》,盡管沒有出版,但其 review 版已在官方博客放出。
1. 實(shí)現(xiàn)一個(gè)網(wǎng)絡(luò)爬蟲
不多說,幾百行代碼實(shí)現(xiàn)高效的網(wǎng)絡(luò)爬蟲, 高效!
項(xiàng)目鏈接:http://aosabook.org/en/500L/a-web-crawler-with-asyncio-coroutines.html
2. Python 實(shí)現(xiàn)數(shù)據(jù)庫
如何用 Python 實(shí)現(xiàn)一個(gè)數(shù)據(jù)庫,支持 query,index, transaction, 兩三百行代碼和對(duì)每個(gè)函數(shù)的講解。看完你就知道知道數(shù)據(jù)庫原理!
項(xiàng)目鏈接:http://aosabook.org/en/500L/an-archaeology-inspired-database.html
3. Python 解析器實(shí)現(xiàn)
手把手教你如何實(shí)現(xiàn) Python 解析器。
項(xiàng)目鏈接:http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html
4. 一個(gè)簡單的計(jì)步器
你用過手機(jī)應(yīng)用記錄你每天走的步數(shù),然后發(fā)送到朋友圈嗎? (沒有? 沒關(guān)系。)這章告訴你如何實(shí)現(xiàn)步數(shù)記錄,怎么算走一步。手機(jī)中有加速記,很容易獲得你某一時(shí)刻在 x,y,z 三個(gè)方向的加速度,用這些參數(shù),如何計(jì)算你走了多少步? 知道嗎? 不知道,看這章,講解加實(shí)現(xiàn)。
項(xiàng)目鏈接:http://aosabook.org/en/500L/a-pedometer-in-the-real-world.html
5. 識(shí)別手寫字母
幾百行代碼使用人工神經(jīng)網(wǎng)絡(luò)實(shí)現(xiàn)識(shí)別手寫字母。
項(xiàng)目鏈接:http://www.aosabook.org/en/500L/optical-character-recognition-ocr.html
6. 一個(gè)簡單的項(xiàng)目模型
Python 是面向?qū)ο笳Z言,對(duì)象,繼承,多態(tài),怎么用代碼實(shí)現(xiàn)的,不到500行代碼,實(shí)際不到400行!
項(xiàng)目鏈接:http://aosabook.org/en/500L/a-simple-object-model.html
7. 靜態(tài)解析器
成熟的 IDE 都有代碼檢查和代碼提示,怎么做的? 看這里。
項(xiàng)目鏈接:http://aosabook.org/en/500L/static-analysis.html
8. 一個(gè)模板引擎
MVC 模型中的 view 層如何解析 html 中的靜態(tài)變量和簡單的語句,如下:
Web 中的 view 層不只是 html 代碼,還有支持其他的代碼。比如 {products}
是一個(gè)變量。 同時(shí) view 層還支持 {if} , {for}, {foreach} 等等。django,velocity 等是如何解析他們的?大牛用不到500行代碼告訴你,是如何實(shí)現(xiàn)的。
項(xiàng)目鏈接:http://aosabook.org/en/500L/a-template-engine.html
9. 一個(gè)3D模型
用 Python 實(shí)現(xiàn)一個(gè)3D設(shè)計(jì),顯示到屏幕,可以交互。
項(xiàng)目鏈接:http://aosabook.org/en/500L/a-3d-modeller.html
10. 電子表格
Web 的電子表格如何實(shí)現(xiàn)的?看這個(gè)經(jīng)典實(shí)現(xiàn)。
項(xiàng)目鏈接:http://aosabook.org/en/500L/web-spreadsheet.html