["python","json","python-2.7"]
What is the difference between json.dump() and json.dumps() in python?

I searched in this official document to find difference between the json.dump() and json.dumps() in python. It is clear that they are related with file write option. But what is the detailed difference between them and in what situations one has more advantage than other?
If you want to dump the JSON into a file/socket or whatever, then you should go with dump(). If you only need it as a string (for printing, parsing or whatever) then use dumps() (dump string) As mentioned by Antti Haapala in this answer, there are some minor differences on the ensure_ascii behaviour. This is mostly due to how the underlying write() function works, being that it operates on chunks rather than the whole string. Check his answer for more details on that. json.dump() Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object If ensure_ascii is False, some chunks written to fp may be unicode instances json.dumps() Serialize obj to a JSON formatted str If ensure_ascii is False, the result may contain non-ASCII characters and the return value may be a unicode instance