-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Dear authors,
running the script train_drawing_classifier.py on a Python 3.6 console generates an error
similar to:
'bitmap_file.write' doesn't accept 'bytes' to write.
with open(bitmap_directory + bitmap_filename, 'w+') as bitmap_file:
bitmap_response = requests.get(bitmap_url + bitmap_filename)
bitmap_file.write(bitmap_response.content)
print('Downloaded %s drawings (category %d/%d)' %
(category, index + 1, total_categories))
I guess the problem lies in the way how the file was opened in the first line, where you opened the file as a text file or the other way around the bitmap_response.content has to be converted to a String.
This small code change helped me to let the script working running without any issues:
with open(bitmap_directory + bitmap_filename, 'wb') as bitmap_file: bitmap_response = requests.get(bitmap_url + bitmap_filename) bitmap_file.write(bitmap_response.content)
which open the file in binary mode to accept bytes to write.
Metadata
Metadata
Assignees
Labels
No labels