Python 2.7은 지원이 종료되었으며 2026년 1월 31일에
지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 Python 2.7 애플리케이션을 배포할 수 없습니다. 기존 Python 2.7 애플리케이션은
지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다.
지원되는 최신 Python 버전으로 마이그레이션하는 것이 좋습니다.
Enum 클래스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Enum 클래스는 새로운 Enum 인스턴스를 초기화하기 위해 사용되는 모든 열거된 유형의 기본 클래스입니다.
Enum
는 protorpc.messages
모듈에서 제공됩니다.
생성자
EnumField 클래스의 생성자는 다음과 같이 정의됩니다.
- class Enum(name, number=None)
-
클래스가 생성될 때 Enum 인스턴스를 자동으로 초기화합니다. 정수 및 문자열이 열거형 값으로 자동으로 변환됩니다.
인수
- name
- 초기화할 Enum 인스턴스의 이름입니다.
- 숫자
- 초기화할 Enum 인스턴스의 숫자입니다.
이미 초기화된 클래스에 대해 호출하면 예외가 발생합니다.
클래스 메서드
Enum 클래스는 다음과 같은 클래스 메소드를 제공합니다.
- to_dict()
- 열거된 클래스의 사전 버전을 만듭니다. 이 사전을 def_num 및 import_enum과 함께 사용할 수 있습니다.
- 열거된 클래스의 사전 이름 및 번호를 반환합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-09-04(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003eEnum\u003c/code\u003e class serves as the foundation for all enumerated types and is used for initializing new \u003ccode\u003eEnum\u003c/code\u003e instances.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eEnum\u003c/code\u003e constructor takes a name and an optional number to initialize an \u003ccode\u003eEnum\u003c/code\u003e instance, automatically casting integers and strings to enum values.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eto_dict()\u003c/code\u003e class method generates a dictionary representation of the enumerated class, mapping names to numbers, for uses like \u003ccode\u003edef_num\u003c/code\u003e and \u003ccode\u003eimport_enum\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# The Enum Class\n\nThe Enum class is the base class for all enumerated types, used to initialize new Enum instances.\n\n`Enum` is provided by the `protorpc.messages` module.\n\nConstructor\n-----------\n\nThe constructor of the EnumField class is defined as follows:\n\nclass Enum(name, number=None)\n\n: Initializes an Enum instance automatically when the class is constructed. Integers and strings are cast automatically to the enum values.\n\n **Arguments**\n\n name\n : The name of the Enum instance to initialize.\n\n number\n : The number of the Enum instance to initialize.\n\n Raises an exception if called on a class that has already been initialized.\n\nClass Methods\n-------------\n\nThe Enum class provides the following class methods:\n\nto_dict()\n: Makes a dictionary version of enumerated class. You can use this dictionary with def_num and import_enum.\n: Returns a dictionary name and number for the enumerated class."]]