Using the http.HTTPStatus class in Python to return the meaning of a HTTP status code

I'm trying to write a block of code to return the meaning (description) of an HTTP status code using the http.HTTPStatus Python class. I read the docs, but it seems I can only do the reverse. Is there way I can do this?

    if resp.status != 200:
        message = 

I don't understand what is your problem.


import http

print( http.HTTPStatus(404).name )

gives description

Back to Top