[Tutor] Writing data to JSON Help
alan.gauld at yahoo.co.uk
Fri Dec 15 18:41:12 EST 2017
On 15/12/17 18:46, Lloyd Walker wrote:
> I'm currently using string formatting to create the json rather than
> creating a dictionary and appending that dictionary to file via the JSON
That's probably your mistake. The standard library is there to
help you get difficult things right. Trying to reinvent it is
a great way to discover how difficult apparently simple things
really are. it's also a terrible way to accomplish anything
> Could you help me create a dictionary using JSON?
> Code: https://gist.github.com/anonymous/42ff1e418ab315c9637f3ffe08ab0a2b
One thing I'd strongly suggest is to separate out your functions.
Your findLinks function does a lot more than find links. Just
return the list of links and create another function to store
them (in whatever format you wish).
Then I suggest you write that new function using the json module.
That will greatly improve your chances of success.
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor