By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,675 Members | 2,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,675 IT Pros & Developers. It's quick & easy.

UnicodeDecodeError: problem when path contain folder start with character 'u'

P: 10
I am facing an error on Unicode decoding of path if it contain a folder/file name starting with character 'u'

Expand|Select|Wrap|Line Numbers
  1. >>> fp = "C:\\ab\\anil"
  2. >>> unicode(fp, "unicode_escape")
  3. u'C:\x07b\x07nil' 
  4. >>> fp = "C:\\ab\\unil"
  5. >>> unicode(fp, "unicode_escape")
  7. Traceback (most recent call last):
  8.   File "<pyshell#41>", line 1, in <module>
  9.     unicode(fp, "unicode_escape")
  10. UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 5-9: end of string in escape sequence
  11. >>> 
I am not sure what is causing this error.
any help appreciated

Jun 22 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,247
I'm guessing it's seeing \unil as Unicode-Escape encoding.

On that page is also an explanation of how to use a string's encode-function, which might be better suited in this case.
Jun 23 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.