To make an HTTP DELETE request in Python, you can use the urllib
library. Specifically, you can use the urllib.request
module's urlopen()
function to send a DELETE request to a specified URL. Here is an example code block showing how to do this:
main.py227 chars10 lines
In this code, we first define the URL that we want to send the DELETE request to. Then we create a Request
object using that URL and specifying the HTTP method as 'DELETE'
. We then use the urlopen()
function to send the DELETE request and retrieve the response. Finally, we decode the response using the UTF-8 encoding and print it.
gistlibby LogSnag