Skip to content Skip to sidebar Skip to footer

Nodejs Pythonshell, How To Export Variables In Run Function

I want to export variable named completed so that I can use this out of PythonShell.run function. Is there any suggestion? here's my code. python code #test.py import sys def hell

Solution 1:

Try using JSPyBridge/pythonia to call the Python script:

Through ES6 imports:

import { python } from'pythonia'const test = awaitpython("./test.py")
await test.hello(2, 3)
python.exit()

Or through CommonJS imports:

const { python } = require('pythonia')
asyncfunctionmain() {
  const test = awaitpython("./test.py")
  await test.hello(2, 3)
}
main().then(() => python.exit())

Post a Comment for "Nodejs Pythonshell, How To Export Variables In Run Function"