Python和GO之间的通信媒介是什么?

huangapple go评论102阅读模式
英文:

Medium of communication between Python and GO?

问题

我想要读写一些特殊格式的保存文件。然而,我目前的能力只能编译Go源代码,然后用Python调用它并返回JSON。

是否有更好的方法在GO!和Python之间进行通信?

英文:

I would like to read and write to some save files with a special format. The extent of my current capabilities, however, would be to compile the go source and then call it with Python and return JSON.

Is there a better way to communicate between GO! and Python?

答案1

得分: 2

Go有一个用于序列化数据的gob格式,但是一些golang-nuts的邮件列表讨论表明它不是与其他语言通信的好选择。

JSON可能是一个非常可靠的选择,或者你可以尝试使用protobufs,这也是上述讨论中提到的。

编辑:
根据你的需求,你也可以尝试使用Thrift进行通信,但这可能不太可能是你正在做的事情的候选项。

英文:

Go has a gob format for serializing data, but some mailing list discussion on golang-nuts suggests that it's not a good choice for communicating with other languages.

JSON would be a very respectable option, or you could try using protobufs which were also suggested in the discussion I linked to above.

EDIT:
You could also try communicating with Thrift depending on your needs, but that's probably a less likely candidate for what you're doing.

答案2

得分: 0

BSON,你可以将其视为JSON的二进制版本,它有许多语言的实现,包括Go和Python。

英文:

There is BSON, which you can think of as a binary version of JSON, with implementations for many languages including Go and Python.

1: http://bsonspec.org/ "BSON"

huangapple
  • 本文由 发表于 2012年9月11日 12:05:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/12362615.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定