Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda