擅长:python、mysql、java
<p>正如所回答的,<code>print</code>和<code>__str__</code>确实有效,但除了调试字符串之外,我不会使用它们。</p>
<p>如果您正在编写用户可以看到的内容,最好使用<a href="https://developers.google.com/protocol-buffers/docs/reference/python/google.protobuf.text_format-module" rel="nofollow noreferrer">^{<cd3>}</a>模块,该模块有更多的控件(例如是否转义UTF8字符串),以及将文本格式解析为protobuf的函数。</p>