Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

You can run the python script in node using exec(): https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

A minimal example assuming you have python3 installed on the machine running your node script could be:

// shell.py
print('printed in python')
// server.js
import {exec} from 'child_process'
//if you don't use module use this line instead:
// const { exec } = require('child_process')
exec('python3 shell.py', (error, stdout, stderr) => {
 if (error) {
 console.log(`error: ${error.message}`);
 return;
 }
 else if (stderr) {
 console.log(`stderr: ${stderr}`);
 }
 else return;{
 }
 console.log(stdout);
 }
})
// using it in the shell
% node server.js
// should output this:
printed in python

This way you could traverse your XML file, change it and output it to the js/ts file, or save it as a file and just read that via your js/ts code.

You can run the python script in node using exec(): https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

A minimal example assuming you have python3 installed on the machine running your node script could be:

// shell.py
print('printed in python')
// server.js
import {exec} from 'child_process'
//if you don't use module use this line instead:
// const { exec } = require('child_process')
exec('python3 shell.py', (error, stdout, stderr) => {
 if (error) {
 console.log(`error: ${error.message}`);
 return;
 }
 if (stderr) {
 console.log(`stderr: ${stderr}`);
 return;
 }
 console.log(stdout)
})
// using it in the shell
% node server.js
// should output this:
printed in python

This way you could traverse your XML file, change it and output it to the js/ts file, or save it as a file and just read that via your js/ts code.

You can run the python script in node using exec(): https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

A minimal example assuming you have python3 installed on the machine running your node script could be:

// shell.py
print('printed in python')
// server.js
import {exec} from 'child_process'
//if you don't use module use this line instead:
// const { exec } = require('child_process')
exec('python3 shell.py', (error, stdout, stderr) => {
 if (error) {
 console.log(`error: ${error.message}`);
 }
 else if (stderr) {
 console.log(`stderr: ${stderr}`);
 }
 else {
 console.log(stdout);
 }
})
// using it in the shell
% node server.js
// should output this:
printed in python

This way you could traverse your XML file, change it and output it to the js/ts file, or save it as a file and just read that via your js/ts code.

Source Link
leonbubova
  • 113
  • 1
  • 6

You can run the python script in node using exec(): https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

A minimal example assuming you have python3 installed on the machine running your node script could be:

// shell.py
print('printed in python')
// server.js
import {exec} from 'child_process'
//if you don't use module use this line instead:
// const { exec } = require('child_process')
exec('python3 shell.py', (error, stdout, stderr) => {
 if (error) {
 console.log(`error: ${error.message}`);
 return;
 }
 if (stderr) {
 console.log(`stderr: ${stderr}`);
 return;
 }
 console.log(stdout)
})
// using it in the shell
% node server.js
// should output this:
printed in python

This way you could traverse your XML file, change it and output it to the js/ts file, or save it as a file and just read that via your js/ts code.

default

AltStyle によって変換されたページ (->オリジナル) /