Skip to content

Instantly share code, notes, and snippets.

@enamhasan
Last active June 27, 2020 12:26
Show Gist options
  • Save enamhasan/ebc08836a86033a939a4efbbba50ccb9 to your computer and use it in GitHub Desktop.
Save enamhasan/ebc08836a86033a939a4efbbba50ccb9 to your computer and use it in GitHub Desktop.
Python Snippets / Cheat Sheet
#=======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