Friday, December 30, 2016

AttributeError: module 'json' has no attribute 'dump'


Today I was trying to create a json file from Python and then I got this error: "AttributeError: module 'json' has no attribute 'dump'" and I found my solution here:


So the problem was I named my file as that was causing problems with json module so renaming it solved the issue.


import json
with open("dump.json", "w") as outfile:
    json.dump({'number':6650, 'strings':'lorem ipsum', 'x':'x', 'y':'y'}, outfile, sort_keys = True, indent=4, ensure_ascii=False)


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.