Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualNercury

Posted 28 February 2013 - 02:45 PM

You can store these things in json file ("example.json"):

 

{
	"monsters": [
		{
			"name": "Rabbit",
			"hp": 30,
			"attack": 5
		},
		{
			"name": "Rat",
			"hp": 40,
			"attack": 10
		}
	]
}

 

And load using python JSON library (included in Python 2.6):

 

import json

config_file = open('example.json')
data = json.load(config_file)
config_file.close()

for monster in data["monsters"]:
    print monster

#1Nercury

Posted 28 February 2013 - 02:44 PM

You can store these things in json file:

 

{
	"monsters": [
		{
			"name": "Rabbit",
			"hp": 30,
			"attack": 5
		},
		{
			"name": "Rat",
			"hp": 40,
			"attack": 10
		}
	]
}

 

And load using python JSON library (included in Python 2.6):

 

import json

config_file = open('test.json')
data = json.load(config_file)
config_file.close()

for monster in data["monsters"]:
    print monster

PARTNERS