我为我的python代码编写了一个api,如下所示:
def greet_in_python(name, greets="Hello"):
## in real life this implementation may be more complex and has other **python** dependencies
....
return greets + " " + name
但是只有 python 开发者可以使用我的 api。
我想要做的是同样的事情,但使用不同的语言,如 javascript,并且无需从 python 重写整个代码。我认为 javascript 必须有一种方法可以与这个 python api 进行通信,执行它并获得结果,以便 javascript 开发人员也可以使用我的 api。
greet_in_javascript(name, greets) {
// talk to my python api
// return the result easily
}
在一般意义上,两种语言如何相互交谈?