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

Time:09-03

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 = 

CodePudding user response:

I don't understand what is your problem.

Code

import http

print( http.HTTPStatus(404).name )

gives description

'NOT_FOUND'
  • Related