【问题标题】:Golang - Python interoperabilityGolang - Python 互操作性
【发布时间】:2021-07-31 20:10:19
【问题描述】:

有没有什么方法可以从 Go 编程语言中使用诸如 pandasnumpyscipypytorch 等 Python 库?

我知道这些库不是用python编写的,而是用c编写的,所以从golang调用函数可能很容易。

【问题讨论】:

  • 请注意,这些库不是用 C 编写的。它们使用用 C 编写的扩展,通过为 Python C-API 编写的包装器,通常通过在蟒蛇。

标签: python go language-interoperability


【解决方案1】:

我不知道它有多实用,但如果它是一小段代码,你可以使用 go 的“os/exec”包来运行它,如下所示:

exec.Command("python",  "-c", "import pythonfile; print pythonfile.cat_strings('foo', 'bar')")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-17
    • 1970-01-01
    • 2010-12-27
    相关资源
    最近更新 更多