Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
¿Cómo imprimo un archivo .json en python?

Me preguntaba si alguien sabe cómo imprimir un archivo .json en python usando el mismo formato que si lo estuviera ejecutando desde JavaScript. Lo estoy usando para el uso de api y la salida es .json pero cuando lo imprimo obtengo esto: enlace a la imagen

Sin embargo, la documentación de la API tiene esto: otra imagen

(Las imágenes muestran diferentes secciones del mismo)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Supongo que te refieres a cómo imprimir un formato json, si es así, podrías hacerlo

 import json with open('yourfile.json', 'r') as handle: parsed = json.load(handle) print(json.dumps(parsed, indent=4, sort_keys=True))

Si quieres hacerlo como Javascript, hay una manera

 var str = JSON.stringify(YourJsonObject, null, 4);

O de otra manera

 import json # Opening JSON file f = open('yourjsonfile.json',) # returns JSON object as # a dictionary data = json.load(f) print(json.dumps(data, indent = 4) # Closing file f.close()

También

 import json print json.dumps(jsonstring, indent=4)
about 4 years ago · Juan Pablo Isaza Report

0

Esto debería funcionar:

 import json print(json.dumps(my_input, sort_keys=True, indent=4))

Consulte https://docs.python.org/3/library/json.html

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!