# - * - Coding: UTF-8 - * "" " status code enum class author: Jill Usage: structure: enum name error - error code code- error description the Message # code print status information code = Status.OK. GET_CODE () Print ( "code:", code) # code Description print status information MSG = Status.OK.get_msg () Print ( "MSG:", MSG) "" " from enum Import the enum, UNIQUE @Unique class the status ( enum): the OK = { " 200 is " : " success " } sUCCESS = { " 000001 " :" Success "} FAIL = { " 000000 " : " Failed " } PARAM_IS_NULL = { " 000002 " : " Request parameter blank " } PARAM_ILLEGAL = { " 000003 " : " Request parameter illegal " } JSON_PARSE_FAIL = { " 000004 " : " the JSON conversion failed " } REPEATED_COMMIT = { " 000005 " : "Repeat submit " } SQL_ERROR = { " 000006 " : " Database Exception " } NOT_FOUND = { " 000007 " : " No Record " } NETWORK_ERROR = { " 000015 " : " Network Anomaly " } UNKNOWN_ERROR = { " 000099 " : " Unknown Exception " } DEF GET_CODE (Self): "" " The status code fetch enumeration name code : return:State code code "" " returnList (self.value.keys ()) [0] DEF get_msg (Self): "" " Description Title taken enumerated status message : return: Description Status message " "" return List (self.value.values ()) [0] IF the __name__ == ' __main__ ' : # print status code information code = Status.OK.get_code () Print ( " code: " , code) # print status code description information MSG = Status.OK.get_msg () Print ( " msg: " , msg) Print () # traversing enumeration for status in Status: print(status.name, ":", status.value)
https://www.cnblogs.com/goingforward/p/10006066.html
https://www.jianshu.com/p/6aeb6502ed1d
https://blog.csdn.net/sikedaima/article/details/86510311 【Java】