UnicodeError for join()

"Martin v. Löwis" martin at v.loewis.de
Thu Jan 15 21:34:14 CET 2009


> rc_file.write("\n\n".join([self.title, "### BEGIN CONTENT ###",
> self.content]))
> .................
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
> 442: ordinal not in range()
> 
> What should I change to make this unicode-safe?

One of self.title and self.content is a Unicode string, the other is
a byte string. You need to change them to have the same type (depending
on whether you want to process them as Unicode or byte strings).

HTH,
Martin



More information about the Python-list mailing list