Last active
January 21, 2022 12:16
-
-
Save hapejot/59b8a0e16b166693a86b61b4ba5db92e to your computer and use it in GitHub Desktop.
Write JSON to 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
| with open("products.json", "r") as read_file: | |
| x = read_file.read() | |
| print(x) |
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
| import json | |
| with open("products.json", "r") as read_file: | |
| all_products = json.load(read_file) | |
| print(all_products) |
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
| import json | |
| all_products = [{"title": "xxx", "link":"http://xxx/", "sku": "what?", "src": "....."}] | |
| with open("products.json", "w") as write_file: | |
| json.dump(all_products, write_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment