看板 Python 關於我們 聯絡資訊
import requests url='http://xxx.xxx.xx' html= requests.get(url).text.splitlines() 我知道get()作用 不過那是書上有寫的到,我試著去看requests模組下get()的code,看不出它是可以取得 網頁內容的東西。 requests模組下還有其他用法requests.xxx() 我要如何知道它還有哪些,並且功能是什麼? 上方requests.get(url) 後面接text.splitlines() 我知道requests.get() 接的原因 書上有寫它的作用,但是我不知道text.splitlines()為什麼可以這樣接,這函式在哪。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.72.106.139 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1483214366.A.A92.html
BigBank: 估狗requests 就有很多用法可以參考了 .text就是其一 01/01 04:25
BigBank: str.splitlines() 是字串內建的方法 詳請可看官方文檔 01/01 04:26
※ 編輯: a82 (211.72.106.139), 01/01/2017 04:44:25
freeunixer: help(requests) ; s = 'str' ; help(str) 01/01 13:55
freeunixer: (s) 01/01 13:56
s860134: 你搞錯了 requests.get(url) 會吐回一個物件 01/01 14:01
s860134: 這個物件下的 text 屬性,類型是内建的 str 型別 01/01 14:02
s860134: 所以 .splitlines 是呼叫這個 str 物件的 method 01/01 14:03
s860134: 簡單來說就是他其實和 requests 沒有關係 01/01 14:03
yinxuanh: type(東東)跑出它是什麼;dir(東東)跑出它有什麼; 01/02 22:24