跳至內容

Requests

本頁使用了標題或全文手工轉換
維基百科,自由的百科全書
Requests
原作者Kenneth Reitz
開發者Kenneth Reitz, Cory Benfield, Ian Stapleton Cordasco, Nate Prewitt
首次發佈2011年2月14日 (2011-02-14)
目前版本
  • 2.32.2 (2024年5月21日;穩定版本)[1]
編輯維基數據連結
原始碼庫 編輯維基數據連結
程式語言Python
作業系統跨平台
許可協定Apache許可證2.0
網站requests.readthedocs.io 編輯維基數據連結

Requests是一個Python HTTP,在Apache License 2.0 許可證下發行。這個專案的目標是使HTTP請求更簡單,更人性化。Requests是沒有預設包含在Python內的最流行的Python庫之一[3],因此有人建議將其預設隨Python一起發佈[4]

範例代碼[編輯]

>>> import requests
>>> r = requests.get('https://httpbin.org/basic-auth/user/pass', auth=('user', 'pass'))
>>> r.status_code
200
>>> r.headers['content-type']
'application/json; charset=utf8'
>>> r.encoding
'utf-8'
>>> r.text
'{"authenticated": true, ...'
>>> r.json()
{'authenticated': True, ...}

參照[編輯]

  1. ^ Release 2.32.2. 2024年5月21日 [2024年5月25日]. 
  2. ^ Community Updates. [2021-03-12]. (原始內容存檔於2021-03-07). 
  3. ^ urllib.request — Extensible library for opening URL. [2021-03-13]. (原始內容存檔於2021-05-28). The Requests package is recommended for a higher-level HTTP client interface. 
  4. ^ Beazly, David. R is for replacement (PDF). login. April 2012, 37 (2) [16 May 2020]. (原始內容 (PDF)存檔於2017-08-24). 

外部連結[編輯]