Python- tutoriaal

Python TUIS Python Intro Python Begin Python-sintaksis Python-kommentaar Python veranderlikes Python-datatipes Python-nommers Python Casting Python Strings Python Booleans Python-operateurs Python-lyste Python Tuples Python-stelle Python Woordeboeke Python As...Anders Python While Loops Python vir lusse Python-funksies Python Lambda Python-skikkings Python-klasse/-voorwerpe Python Erfenis Python Iterators Python-omvang Python-modules Python-datums Python Wiskunde Python JSON Python RegEx Python PIP Python Probeer ... Behalwe Python-gebruikersinvoer Python String Formatering

Lêerhantering

Python-lêerhantering Python Lees lêers Python Skryf/skep lêers Python verwyder lêers

Python-modules

NumPy Tutoriaal Panda Walkthrough Scipy Tutoriaal

Python Matplotlib

Matplotlib Intro Matplotlib Begin Matplotlib Pyplot Matplotlib Plotte Matplotlib Merkers Matplotlib-lyn Matplotlib-etikette Matplotlib-rooster Matplotlib Subplotte Matplotlib Scatter Matplotlib Bars Matplotlib Histogramme Matplotlib sirkeldiagramme

Masjienleer

Aan die gang kom Gemiddelde mediaanmodus Standaard afwyking Persentiel Dataverspreiding Normale dataverspreiding Strooi plot Lineêre regressie Polinoomregressie Meervoudige regressie Skaal Trein/toets Besluitboom

Python MySQL

MySQL Begin MySQL Skep databasis MySQL Skep tabel MySQL-insetsel MySQL Kies MySQL Waar MySQL Bestel deur MySQL verwyder MySQL Drop Table MySQL-opdatering MySQL-limiet MySQL Sluit aan

Python MongoDB

MongoDB Begin MongoDB Skep databasis MongoDB Skep versameling MongoDB-insetsel MongoDB Vind MongoDB-navraag MongoDB Sorteer MongoDB verwyder MongoDB Drop Collection MongoDB-opdatering MongoDB-limiet

Python-verwysing

Python Oorsig Python ingeboude funksies Python-stringmetodes Python Lys Metodes Python Woordeboek Metodes Python Tuple Metodes Python Stel metodes Python-lêermetodes Python sleutelwoorde Python-uitsonderings Python Woordelys

Moduleverwysing

Ewekansige module Versoeke Module Statistiek Module Wiskunde Module cMath-module

Python Hoe om

Verwyder lys duplikate Draai 'n snaar om Voeg twee getalle by

Python voorbeelde

Python voorbeelde Python-samesteller Python-oefeninge Python Vasvra Python-sertifikaat

Python-versoeke. Reaksievoorwerp _

❮ Versoekmodule


Voorbeeld

Maak 'n versoek na 'n webblad en gee die statuskode terug:

import requests

x = requests.get('https://w3schools.com')
print(x.status_code)

Definisie en gebruik

Die requests.Response()objek bevat die bediener se reaksie op die HTTP-versoek.


Eienskappe en metodes

Property/Method Description
apparent_encoding Returns the apparent encoding
close() Closes the connection to the server
content Returns the content of the response, in bytes
cookies Returns a CookieJar object with the cookies sent back from the server
elapsed Returns a timedelta object with the time elapsed from sending the request to the arrival of the response
encoding Returns the encoding used to decode r.text
headers Returns a dictionary of response headers
history Returns a list of response objects holding the history of request (url)
is_permanent_redirect Returns True if the response is the permanent redirected url, otherwise False
is_redirect Returns True if the response was redirected, otherwise False
iter_content() Iterates over the response
iter_lines() Iterates over the lines of the response
json() Returns a JSON object of the result (if the result was written in JSON format, if not it raises an error)
links Returns the header links
next Returns a PreparedRequest object for the next request in a redirection
ok Returns True if status_code is less than 400, otherwise False
raise_for_status() If an error occur, this method returns a HTTPError object
reason Returns a text corresponding to the status code
request Returns the request object that requested this response
status_code Returns a number that indicates the status (200 is OK, 404 is Not Found)
text Returns the content of the response, in unicode
url Returns the URL of the response

❮ Versoekmodule