1

Topic: Python a sheet element

I continue to study Pajton.
Is available json .
I read out it:
[SRC Python
]inputFile = "json/input.json"
myfile = open (inputFile, "r")
result = myfile.read ()
json_data = json.loads (result)
[/code]
Now I want to change a little json and to write down in new .
But

for user in json_data:
score = user ["score"]
score = score + 50
user ["score"] = score

Does not work. As here  it is necessary!?

2

Re: Python a sheet element

Made so:

import json
print ("Content-type: text/html")
print ()
print ("test script is run!!!!")
newJSON = []
inputFile = "json/input.json"
outputFile = "json/output.json"
myfile = open (inputFile, "r")
result = myfile.read ()
json_data = json.loads (result)
for user in json_data:
score = int (user ["score"])
score + = 50
row = [user ["playerName"], user ["score"], user ["group"], user ["status"]]
# print (row)
newJSON.append (row)
print ("List was updated!")
myFile1 = open (outputFile, "w")
json.dump (newJSON, myFile1)
myFile1.close ()
print ("This script finished work!")

Works. And whether it is possible as  on more refined!