Tag Archives: unicode

Dealing with unicode in Python

Posted on by 2 comments

I say transliterating, but I really just mean coping with strings involving unprintable characters…

 

Today I came across a neat little trick which I hope helps you as much as I.

take the following print statement

print "blahÆlec"

this will break

but there are some cases where exact spelling isn’t important you just to to out put the data so you can glace at it, you can actually give the str decode method a nifty argument “ignore” eg.

print "blahÆlec".decode("ascii","ignore")

and this simply drops the unprintable characters.

Success

Category: Python | Tags: , ,