प्रोटोकॉल मैसेज को प्रोसेस करने के लिए मॉड्यूल.
सदस्य
encode_text
string proto.encode_text(x)
स्ट्रक्ट को मैसेज में बदला जाता है. फ़ील्ड को नाम के हिसाब से क्रम में लगाया जाता है. स्ट्रक्चर के हर उस फ़ील्ड को अनदेखा किया जाता है जिसकी वैल्यू None होती है.
किसी क्रम (जैसे कि सूची या टपल) को बार-बार इस्तेमाल किए जाने वाले फ़ील्ड में बदल दिया जाता है. इसके एलिमेंट, सीक्वेंस या डिक्ट नहीं होने चाहिए.
डिक्शनरी को 'key' और 'value' नाम वाले फ़ील्ड के साथ, मैसेज के दोहराए गए फ़ील्ड में बदल दिया जाता है.
एंट्री, क्रम से (इंसर्शन) दोहराई जाती हैं.
डिक्शनरी की कुंजियां, स्ट्रिंग या पूर्णांक होनी चाहिए. साथ ही, इसकी वैल्यू, सीक्वेंस या डिक्शनरी नहीं होनी चाहिए.
उदाहरण:
proto.encode_text(struct(field=123)) # field: 123 proto.encode_text(struct(field=True)) # field: true proto.encode_text(struct(field=[1, 2, 3])) # field: 1 # field: 2 # field: 3 proto.encode_text(struct(field='text', ignored_field=None)) # field: "text" proto.encode_text(struct(field=struct(inner_field='text', ignored_field=None))) # field { # inner_field: "text" # } proto.encode_text(struct(field=[struct(inner_field=1), struct(inner_field=2)])) # field { # inner_field: 1 # } # field { # inner_field: 2 # } proto.encode_text(struct(field=struct(inner_field=struct(inner_inner_field='text')))) # field { # inner_field { # inner_inner_field: "text" # } # } proto.encode_text(struct(foo={4: 3, 2: 1})) # foo: { # key: 4 # value: 3 # } # foo: { # key: 2 # value: 1 # }
पैरामीटर
पैरामीटर | ब्यौरा |
---|---|
x
|
स्ट्रक्चर;
ज़रूरी है |