"string indices must be integers"
Go to solution
Solved by Mr_KoKa,
The "saving it" part is wrong. Just ditch this line
jsonData = json.dumps(data) # Here is '{"Attack": "1"}'
and change this line
json.dump(jsonData, f) # And now it is '"{\"Attack\": \"1\"}"'
to
json.dump(data, f) # And now it is '"{\"Attack\": \"1\"}"'
So now you don't encode data to json and save it to jsonData and then encode it again and save to file, but now you just encode your data (dictionary) once right into the file. And then you load it from file as you did, decoding it once. Once encoded once decoded, it just works.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now