No need to convert to string using json.dumps ()
>>> f = open("t.txt",'w') >>> r = {'is_claimed': 'True', 'rating': 3.5} >>> f.write(r['is_claimed']) >>> f.write(r['rating']) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: expected a character buffer object
should be a string to write to the file, but the rating value is float, so convert to string first, and then try. It works reliably.
user3273866 Nov 05 '14 at 7:44 2014-11-05 07:44
source share