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?

try:
    if resp.status != 200:
        message = 

I don't understand what is your problem.

Code

import http

print( http.HTTPStatus(404).name )

gives description

'NOT_FOUND'
Back to Top