unicode error

jean-michel bain-cornu jmbc at nospam.fr
Fri Mar 17 15:16:40 EST 2006


Allerdyce.John at gmail.com wrote:
> I have this python code:
> print >> htmlFile, "<div id=\"track" + unicode(1) + "\"
> style=\"width: 200px; height:18px;\">";
> 
> 
> But that caues this error, and I can't figure it out why. Any help is
> appreicate
>  File "./run.py", line 193, in ?
>     print >> htmlFile, "<div id=\"track" + unicode(1) + "\"
> style=\"width: 200px; height:18px;\">";
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9:
> ordinal not in range(128)
> 
> Thanks.
> 
Hi,
I tried and it worked (wrote into the file:<div id="track1"style="width: 
200px; height:18px;">).
Can you try to isolate exactly what part of the code is wrong ?
jm
Here is the complete code:
htmlfile=file('jmbc.txt','w')
print >> htmlfile, "<div id=\"track" + unicode(1) + "\"style=\"width: 
200px; height:18px;\">";
htmlfile.close()



More information about the Python-list mailing list