Quantcast
Channel: Kai Zhou's Blog
Viewing all articles
Browse latest Browse all 10

Fix python writelines() argument must be a sequence of strings

$
0
0

 

when using python write unicode string into a file, it may throw below exception:

f.writelines(line)
TypeError: writelines() argument must be a sequence of strings

 

we need to change the code to below:

f.writelines(line.encode('utf8'))

 

I have tried, after change the code, exception fixed.

 

 


Viewing all articles
Browse latest Browse all 10

Trending Articles