Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
How to start all print by a tab in Python

I have a script (in Python), that is called by another script (in JavaScript). And to have better readability of the log in my command line, I'd like that all the prints of the subscript (in Python) start with a tabulation. Is there a way to do that with one command, or should I put manually a \t at the beginning of all my print?

I wanted to add the tab in the calling script, but when there are several prints in a row, only the first one gets the tab.

PS: if it can help, the calling of the Python script:

const spawn = require("child_process").spawn;
const pythonProcess = spawn('python3', ["../pythonscript.py"]);
pythonProcess.stdout.on('data', (data) => {          
  buff = Buffer.from(data.toString().trim(), "utf-8");

  console.log('Python answer = ' + buff.toString());
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think this is clearly a post-processing step to be done in Javascript.

Unless you have complete control over your script, there is lots of ways how things might be printed without tab:

  • Strings containing \n
  • automatic log/warning messages from libraries
  • Forgetting the prefix somewhere
  • etc.

Just use buff.toString().split("\n").join("\n\t") in JS.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda