My following python code works for Python 2,
if header_written == False:
header = out_data.keys()
writer.writerow(out_data.keys()) # write headers
header_written = True
writer.writerow(out_data.values()) #write rows
del out_data #del object
del row_data #del dict object
but in Python 3, it returns the following error:
TypeError: a bytes-like object is required, not 'str'
You have to convert it to bytes. You can do it like this.
bytes = string.encode(encoding='UTF-8')
More info here
Best way to convert string to bytes in Python 3?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With