我想從JavaScript代碼中調(diào)用Python函數(shù),因為在JavaScript中沒有替代方法可以執(zhí)行我想要的操作。這可能嗎?你能調(diào)整下面的片段嗎?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 包含使用高級庫的函數(shù),這些庫在JavaScript中沒有易于編寫的等價物:import nltk # is not in JavaScriptdef processParagraph(text): ... nltk calls ... return lst # returns a list of strings (will be converted to JavaScript array)
從JavaScript代碼調(diào)用Python函數(shù)
手掌心
2019-08-30 17:22:52