Tutorial Python

RUMAH Python Pengenalan Python Python Memulai Sintaks Python Komentar Python Variabel Python Tipe Data Python Nomor Python Pengecoran Python String Python Python Boolean Operator Python Daftar Python Tuple Python Set Python Kamus Python Python Jika...Lain Python Sementara Loop Python Untuk Loop Fungsi Python Python Lambda Array Python Kelas/Objek Python Warisan Python Python Iterator Lingkup Python Modul Python Tanggal Python Python Matematika Python JSON Python RegEx Python PIP Python Coba...Kecuali Masukan Pengguna Python Pemformatan String Python

Penanganan Berkas

Penanganan File Python File Baca Python Python Tulis/Buat File Python Hapus File

Modul Python

Tutorial NumPy Panduan Panda Tutorial sip

Python Matplotlib

Pengantar Matplotlib Matplotlib Memulai Matplotlib Pyplot Merencanakan Matplotlib Penanda Matplotlib Garis Matplotlib Label Matplotlib Kotak Matplotlib Subplot Matplotlib Penyebaran Matplotlib Matplotlib Bar Histogram Matplotlib Bagan Pai Matplotlib

Pembelajaran mesin

Mulai Mode Median Rata-rata Standar Deviasi Persentil Distribusi Data Distribusi Data Normal Plot Pencar Regresi linier Regresi Polinomial Regresi Berganda Skala Kereta/Tes Pohon Keputusan

Python MySQL

MySQL Memulai MySQL Buat Basis Data MySQL Buat Tabel Sisipan MySQL MySQL Pilih MySQL Dimana MySQL Dipesan Oleh Hapus MySQL Tabel Drop MySQL Pembaruan MySQL Batas MySQL MySQL Bergabung

Python MongoDB

MongoDB Memulai MongoDB Buat Basis Data MongoDB Buat Koleksi Sisipan MongoDB Temukan MongoDB Permintaan MongoDB Sortir MongoDB Hapus MongoDB Koleksi Jatuhkan MongoDB Pembaruan MongoDB Batas MongoDB

Referensi Python

Ikhtisar Python Fungsi bawaan Python Metode String Python Metode Daftar Python Metode Kamus Python Metode Tuple Python Metode Set Python Metode File Python Kata Kunci Python Pengecualian Python Daftar Istilah Python

Referensi Modul

Modul Acak Modul Permintaan Modul Statistik Modul Matematika Modul cMath

Python Bagaimana caranya?

Hapus Duplikat Daftar Membalikkan String Tambahkan Dua Angka

Contoh Python

Contoh Python Kompilator Python Latihan Python Kuis Python Sertifikat Python

permintaan Python. Objek Respon

Modul Permintaan


Contoh

Buat permintaan ke halaman web, dan kembalikan kode status:

import requests

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

Definisi dan Penggunaan

Objek requests.Response()berisi respons server terhadap permintaan HTTP.


Properti dan Metode

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

Modul Permintaan