Hi When I try and save a dictionary to a csv using the following code:
with open(file, 'wb') as f: # Just use 'w' mode in 3.x
w = csv.DictWriter(f, my_dictionary.keys())
w.writeheader()
w.writerow(my_dictionary)
I get this error message
TypeError: a bytes-like object is required, not 'str'
Is there a fix for this?
wmode, notwbmode. The old bug for blank lines between rows in Windows is now fixed in Python 3 by addingnewline=''instead of opening inwbmode.