Why can I not convert my existing byte string into a unicode string? In the mean time I'll create my original string as unicode and see if that solves my problem.
>>> fileName = unicode(filename) Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c in position 35: invalid start byte -- James At Thursday, 28/06/2012 on 18:58 Jerry Hill wrote: On Thu, Jun 28, 2012 at 1:55 PM, James Chapman wrote: > Thanks Tim, while this works, I need the name to be stored in a variable as > it's dynamic. > > In other words, how do I rewrite > open(u"blah£.txt") > > to be > filename = "blah£.txt" > open(filename) You have to create a unicode-string, not a byte-string. So, like this: filename = u"blah£.txt" open(filename) -- Jerry
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor