SyntaxFix
Write A Post
Hire A Developer
Questions
You need to open the file in binary b mode to take care of blank lines in Python 2. This isn't required in Python 3.
b
So, change open('test.csv', 'w') to open('test.csv', 'wb').
open('test.csv', 'w')
open('test.csv', 'wb')