We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70b8a82 commit 0aaa25aCopy full SHA for 0aaa25a
libs/python.wiki
@@ -394,6 +394,27 @@ page = handle.read()
394
handle.close()
395
</source>
396
397
+<h4>Requests</h4>
398
+
399
+Home:[http://www.python-requests.org/]
400
401
+这是一个用起来很优雅的库,如其名,封装了 HTTP 请求的功能。
402
403
+代码示例
404
+<source lang="python">
405
+>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
406
+>>> r.status_code
407
+200
408
+>>> r.headers['content-type']
409
+'application/json; charset=utf8'
410
+>>> r.encoding
411
+'utf-8'
412
+>>> r.text
413
+u'{"type":"User"...'
414
+>>> r.json()
415
+{u'private_gists': 419, u'total_private_repos': 77, ...}
416
+</source>
417
418
== 4.2 HTTP Server ==
419
420
<h4>SimpleHTTPServer & http.server</h4>
0 commit comments