文章詳情頁
python 導(dǎo)包 `from _collections import deque, defaultdict`
瀏覽:87日期:2022-07-20 16:48:03
問題描述
昨天很偶然的看到這一行代碼from _collections import deque
我當時是在看python 的庫文檔來著,看到collections 的時候,我就去找deque的源代碼,然后去找 _collections ,但是Lib目錄下并沒有找到,使用查找文件的時候發(fā)現(xiàn)目錄Lib/site-packages/requests/packages/urllib3/_collections.py ,但是里面并沒有有關(guān)于deque的代碼,所有我就很好奇from _collections import deque ,這個 _collections 到底哪兒來的
問題解答
回答1:這里
https://github.com/python/cpy...
回答2:內(nèi)建模塊,類似以c擴展
In [4]: import _collections
In [5]: _collectionsOut[5]: <module ’_collections’ (built-in)>
回答3:_collections是一個內(nèi)置模塊, 要從源碼查找: Python-2.7.12/Modules/_collectionsmodule.c
排行榜

熱門標簽