Python 2.7 已終止支援,並將於 2026 年 1 月 31 日
淘汰。淘汰後,您將無法部署 Python 2.7 應用程式,即使貴機構先前曾使用機構政策重新啟用舊版執行階段的部署作業,也無法部署。現有的 Python 2.7 應用程式在
淘汰日期過後,仍會繼續執行並接收流量。建議您
改用系統支援的最新 Python 版本。
Variant 類別
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
protobuf
傳輸格式使用 Variant 類別來決定單一資料的傳輸方式。其他格式也可能使用;詳情請參閱「通訊協定緩衝區編碼」。
Variant
由 protorpc.messages
模組提供。
Variant 的值如下:
BOOL
- 布林值 (True 或 False)
BYTES
- 8 位元位元組的字串。
DOUBLE
- 64 位元浮點數。
ENUM
- 列舉值 (整數)。
FLOAT
- 32 位元浮點數。
INT32
- 32 位元帶正負號整數。
INT64
- 64 位元帶正負號整數。
MESSAGE
- 以位元組字串形式嵌入訊息。
SINT32
- 32 位元帶正負號整數。使用 ZigZag 編碼。
SINT64
- 64 位元帶正負號整數。使用 ZigZag 編碼。
STRING
- UTF-8 編碼文字的字串。
UINT32
- 32 位元不帶正負號整數。
UINT64
- 64 位元無正負號整數。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-04 (世界標準時間)。
[[["容易理解","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 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eprotobuf\u003c/code\u003e wire format utilizes the \u003ccode\u003eVariant\u003c/code\u003e class to define data transmission.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eVariant\u003c/code\u003e, found in the \u003ccode\u003eprotorpc.messages\u003c/code\u003e module, specifies the type of data being transmitted.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eVariant\u003c/code\u003e supports various data types, including boolean, byte strings, floating-point numbers, enums, integers, and embedded messages.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eVariant\u003c/code\u003e can utilize ZigZag encoding for signed integers using \u003ccode\u003eSINT32\u003c/code\u003e and \u003ccode\u003eSINT64\u003c/code\u003e types.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSTRING\u003c/code\u003e type is used for UTF-8 encoded text.\u003c/p\u003e\n"]]],[],null,["# The Variant Class\n\nThe `protobuf` wire format uses the Variant class to determine how to transmit a single piece of data. May be used by other formats; see [Protocol Buffers Encoding](https://developers.google.com/protocol-buffers/docs/encoding) for more information.\n\n`Variant` is provided by the `protorpc.messages` module.\n\nVariant has the following values:\n\n`BOOL`\n: Boolean value (True or False)\n\n`BYTES`\n: String of 8-bit bytes.\n\n`DOUBLE`\n: 64-bit floating point number.\n\n`ENUM`\n: Enum value (an integer).\n\n`FLOAT`\n: 32-bit floating point number.\n\n`INT32`\n: 32-bit signed integer.\n\n`INT64`\n: 64-bit signed integer.\n\n`MESSAGE`\n: Embedded message as byte string.\n\n`SINT32`\n: 32-bit signed integer. Uses [ZigZag encoding](https://developers.google.com/protocol-buffers/docs/encoding#types).\n\n`SINT64`\n: 64-bit signed integer. Uses [ZigZag encoding](https://developers.google.com/protocol-buffers/docs/encoding#types).\n\n`STRING`\n: String of UTF-8-encoded text.\n\n`UINT32`\n: 32-bit unsigned integer.\n\n`UINT64`\n: 64-bit unsigned integer."]]