Is there any way to do HTTP PUT request in Python?

I’ve used a variety of python HTTP libs in the past, and I’ve settled on requests as my favourite. Existing libs had pretty useable interfaces, but code can end up being a few lines too long for simple operations. A basic PUT in requests looks like:

payload = {'username': 'bob', 'email': ''}
>>> r = requests.put("", data=payload)

You can then check the response status code with:


or the response with:


Requests has a lot synactic sugar and shortcuts that’ll make your life easier.

Leave a Comment