我想要运行函数来阻止表的每一行。我想在加载 HTML 代码后执行此操作,我尝试这样做
<body>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.js"
></script>
<script type="text/javascript">
async function main(kw) {
let pyodide = await loadPyodide({
indexURL: "https://cdn.jsdelivr.net/pyodide/dev/full/",
});
pyodide.globals.set("mikw", kw);
await pyodide.loadPackage("micropip");
await pyodide.runPythonAsync(`
import micropip
import js
await micropip.install('snowballstemmer')
import snowballstemmer
stemmer = snowballstemmer.stemmer('english')
div = js.document.createElement("div")
div.innerHTML = stemmer.stemWords('Hello this my default text '.split())
js.document.body.prepend(div)
varP = js.document.getElementById('origen').textContent
print(varP)
salida = stemmer.stemWords(varP.split())
print(salida)
divSalida = js.document.createElement("div")
div.innerHTML =salida
salida = stemmer.stemWords(mikw.split())
print(salida)
`);
}
main('This are the second text, I put this text on …Run Code Online (Sandbox Code Playgroud)