为了账号安全,请及时绑定邮箱和手机立即绑定

从JavaScript代码调用Python函数

从JavaScript代码调用Python函数

手掌心 2019-08-30 17:22:52
我想从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)
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 3929 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信