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

从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 关注
  • 3935 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号