[英]How to unset a protocol buffer field?
How would you unset a protocol buffer variable.您将如何取消设置协议缓冲区变量。
Given this .proto
:鉴于此.proto
:
message Product {
optional float price = 5;
}
If one tries deleting the item:如果有人尝试删除该项目:
del product.price
this results:结果:
AttributeError: can't delete attribute
If one tries setting the variable to None
:如果有人尝试将变量设置为None
:
product.price = None
this results:结果:
TypeError: Cannot set mypackage.Product.price_was to None: None has type <class 'NoneType'>, but expected one of: numbers.Real
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.