python: How do i download a file from Google drive using api

just write the content variable to a file instead of returning the content

fo = open("foo.jpg", "wb")
fo.write(content)
fo.close()

I think you should probably check out this:

http://pythonhosted.org/PyDrive/

The code seems like it is easier

# Initialize GoogleDriveFile instance with file id.
file6 = drive.CreateFile({'id': file5['id']})
file6.GetContentFile('catlove.png') # Download file as 'catlove.png'.

# Initialize GoogleDriveFile instance with file id.
file7 = drive.CreateFile({'id': file4['id']})
content = file7.GetContentString()
# content: '{"firstname": "Claudio", "lastname": "Afshar"}'