[問題] 關於模組

看板Python作者 (QQ)時間9年前 (2016/12/24 13:42), 編輯推噓2(207)
留言9則, 4人參與, 最新討論串1/1
書上寫requests是一個模組 我用python shell 打上requests 也顯示是module 它顯示到最後是一個__int__.py 而不是requests.py <module 'requests' from 'C:\.......\\Python35\\lib\\requests\\__init__.py'> 我的認知是模組是一個py檔 目前我會的是這樣 所以我也看不懂requests.get() 那get()到底在哪 我認為get()應該在在一個requests.py 檔內 我是哪裡弄錯了呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.198.185.78 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1482558143.A.D26.html

12/24 15:25, , 1F
小模組
12/24 15:25, 1F

12/24 17:59, , 2F
都有 source code, 你打開 __init__.py 看看就知道了
12/24 17:59, 2F

12/24 18:34, , 3F
我打開了 但不懂什麼意思 我也找不到get阿
12/24 18:34, 3F

12/24 20:35, , 4F
裡面不是有一行 get 的 import 敘述 ?
12/24 20:35, 4F

12/24 20:36, , 5F
from .api import request, get, head, post, patch
12/24 20:36, 5F

12/24 20:37, , 6F
所以你才可以用 requests.get(), requests.post() 這類
12/24 20:37, 6F

12/24 20:37, , 7F
get() 這類 function 在 api.py 檔案內
12/24 20:37, 7F

12/25 00:34, , 8F
感謝你
12/25 00:34, 8F
文章代碼(AID): #1ONWg_qc (Python)
文章代碼(AID): #1ONWg_qc (Python)