我想从JavaScript代码中调用Python函数,因为在JavaScript中没有替代方法可以执行我想要的操作。这可能吗?你能调整下面的片段吗?JavaScript代码:var tag = document.getElementsByTagName("p")[0];text = tag.innerHTML;// Here I would like to call the Python interpreter with Python functionarrOfStrings = openSomehowPythonInterpreter("~/pythoncode.py", "processParagraph(text)");~/pythoncode.py 包含使用高级库的函数,这些库在JavaScript中没有易于编写的等价物:import nltk # is not in JavaScriptdef processParagraph(text): ... nltk calls ... return lst # returns a list of strings (will be converted to JavaScript array)
添加回答
举报
0/150
提交
取消