Created
June 22, 2022 06:58
-
-
Save themegabyte/ec80aadfeae983161ec8a1b6504baae8 to your computer and use it in GitHub Desktop.
A quick function to dump python list to .json file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def json_dump(data: list): | |
| t = [] | |
| for idx, row in enumerate(data): | |
| _t = {'id': idx, 'data': row} | |
| t.append(_t) | |
| with open('test.json', 'w', encoding='utf-8') as f: | |
| json.dump(t, f, | |
| ensure_ascii=False, indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment