问题描述
我似乎无法在 API 中找到比较方法.我有这两条消息,它们有很多不同的值,有时会深入到更多值(例如,我有一个消息,其中包含一个字符串、一个整数和一个 custom_snapshot,其中 custom_snapshot 由一个 int、一个字符串等).我想看看这两个消息是否相同.我不想一个一个比较每个值,因为这需要一段时间,所以我想知道在 Python 中是否有一种快速的方法来做到这一点?
I can't seem to find a comparison method in the API. I have these two messages, and they have a lot of different values that sometimes drill down to more values (for example, I have a Message that has a string, an int, and a custom_snapshot, where custom_snapshot is comprised of an int, a string, and so on). I want to see if these two messages are the same. I don't want to compare each value one by one since that will take a while, so I was wondering if there was a quick way to do this in Python?
我尝试执行 messageA.debugString() == messageB.debugString(),但显然没有我尝试时可以访问的 debugString 方法.
I tried doing messageA.debugString() == messageB.debugString(), but apparently there is no debugString method that I could access when I tried.
推荐答案
protocol buffers 有一个方法 SerializeToString()
protocol buffers have a method SerializeToString()
用它来比较您的消息.
这篇关于如何比较两个 Google Protocol Buffer 消息的内容是否相等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!