您将如何在 google protobufs 中为 python 设置 DoubleValue

How would you set DoubleValue in google protobufs for python

我有一个 DoubleValue 类型的字段,如何在 python 中用浮点数设置它?目前,如果我用浮点数设置它,我会收到错误消息:

Parameter to MergeFrom() must be instance of same class: expected DoubleValue got float.

我试过这个:DoubleValue(1.23) 但它不起作用。没有完全理解这个 class.

我目前也在 python 构造函数中设置它

ParentClass(value=DoubleValue(1.0))

DoubleValue有一个属性value,可以在构造函数中设置。

DoubleValue(value=1.23)

遇到同样的问题,但发现 属性 隐藏在 documentation.