英文:
how to share variable between python and go language?
问题
我需要知道如何在两个程序之间共享变量,
基本上,Go程序需要写入一个变量,比如一个字符串,而Python程序需要读取这个变量。
请帮助我,提前感谢你。
英文:
i need to know how share variable between two program,
basically the go program have to write a variable ,like a string, and the python program have to read this variable.
Please help me, thank you in advance.
答案1
得分: 1
使用标准流。使用简单的printf
类型命令将字符串打印到标准输出。然后在Python中使用raw_input()
读取它。
像这样运行这两个程序:
./output | ./read.py
英文:
use standard streams. use a simple printf
type command to print the string to stdout. then read it with a raw_input()
in python.
run the two programs like so:
./output | ./read.py
答案2
得分: 1
在Windows中,两个进程之间进行通信的最常见方式是“命名管道”(也可以是tcp/ip、web服务等)。
一种丑陋但更轻量的方式是将值写入文件,然后从Python中读取。
英文:
In Windows, most common way to do communication between two processes is "Named Pipe" (could also be tcp/ip, web service, etc...).
A ugly but lighter way is to write the value to a file, and read it from python.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论