Lucky Spin: Godly Programming

Chapter 47: Finishing PersonalForge



With that, what he created next was export functions for JSON, PDF, or HTML.

So he typed the necessary code to handle each export format.

...

python

import json

def export_profile(profile_dict, filename="identity.json"):

with open(filename, ’w’) as f:

json.dump(profile_dict, f, indent=4)

...

This function saves a fake identity stored in a Python dictionary into a JSON file.

The variable profile_dict holds the generated identity, and filename refers to the output file name, which defaults to identity.json.

If you find any errors ( Ads popup, ads redirect, broken links, non-standard content, etc.. ), Please let us know < report chapter > so we can fix it as soon as possible.

Tip: You can use left, right, A and D keyboard keys to browse between chapters.