import json
      
      with open("filename", "w") as f:
        f.write(json.dumps("json_content", indent=2))

      Python language logo
      Write JSON to in a file

      Python public recipes

      The code opens the file "filename.json" in "w" mode, writes the JSON content to the file, and indents the code two spaces.

      Shortcut: json.write.tofile

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.