Last active
June 27, 2020 12:26
-
-
Save enamhasan/ebc08836a86033a939a4efbbba50ccb9 to your computer and use it in GitHub Desktop.
Python Snippets / Cheat Sheet
This file contains 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
#=======Save a dict to json file============= | |
import json | |
dict = {'Python' : '.py', 'C++' : '.cpp', 'Java' : '.java'} | |
json = json.dumps(dict) | |
f = open("dict.json","w") | |
f.write(json) | |
f.close() | |
#=======Save a dict to text file============= | |
dict = {'Python' : '.py', 'C++' : '.cpp', 'Java' : '.java'} | |
f = open("dict.txt","w") | |
f.write( str(dict) ) | |
f.close() | |
#===== Read a specific element in json | |
data = response.json() | |
#Read specific node (variant) data | |
inventory_item_id=data['variant']['inventory_item_id'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment