前言
又遇新框架,迷糊找接口。
隔日又更新,版本多如狗。
中文找不着,英文看不懂。
源碼鏈不進,鏈進鏈不盡。
捂臉問大神,傳女不傳男。
終日不成章,泣涕零如雨。
紙上終覺淺,debug要躬行!
上網找教學文檔
- 博客、論壇等:最常用的方式,可以快速入門
- 官方文檔:一堆英文噢,反正很少用
- 教學視頻:系統學習,先學原理再學接口,比較耗時
Debug模式
Pycharm帶Debug模式,先點紅一段代碼,然後Shift+F9
看源碼
- Pycharm的Ctrl+鼠標右鍵可以鏈到源碼,但有時候鏈不到
- 找到包的路徑(例如:
Anaconda3\Lib\site-packages
),單獨複製出來,這樣還能看到整個目錄架構
內置函數dir和help
def find_api(thing):
for i in dir(thing):
try:
j = eval('thing.' + i)
print('\033[031m{}\033[0m'.format(i), j)
except:
pass
from pandas import DataFrame
find_api(DataFrame)
help(DataFrame)
詳細一點的版本
def find_not_startwith(thing, prefix='_'):
for i in dir(thing):
try:
j = eval('thing.' + i)
if not i.startswith(prefix):
print('\033[033m{}\033[0m'.format(i), j)
except:
pass
def find_isinstance(thing, t=(str, int, dict, list, tuple, float)):
for i in dir(thing):
try:
j = eval('thing.' + i)
if isinstance(j, t):
print('\033[033m{}\033[0m'.format(i), j)
except:
pass
def find_callable(thing):
for i in dir(thing):
try:
j = eval('thing.' + i)
if callable(j):
print('\033[033m{}\033[0m'.format(i), j)
except:
pass
import collections
find_not_startwith(collections);print('-'*50)
find_isinstance(collections);print('-'*50)
find_callable(collections);print('-'*50)
問人
問問朋友或同事,順便增進下感情
發論壇,出賞金(沒試過,不造行不行)