python - Unicode escape error -


experts!

i'm trying make twitter client, twython. now, retrieve command interactive interpreter.

in test upload picture, passed string:

   "tweet photo: 'tweeted python test' + path: 'c:\users\akhya_000\pictures\my pictures\bing.png" 

but found invalid , resulted in error:

syntaxerror: (unicode error) 'unicodeescape' codec can't decode bytes in position 51-52: truncated \uxxxxxxxx escape 

can me, what's wrong string? should fix it?

you want escape backslashes or use raw string, since python seeing \u , interpreting unicode escape sequence.

escaping looks this:

"tweet photo: 'tweeted python test' + path: 'c:\\users\\akhya_000\\pictures\\my pictures\\bing.png" 

a raw string, python ignore escape sequences, looks this:

r"tweet photo: 'tweeted python test' + path: 'c:\users\akhya_000\pictures\my pictures\bing.png" 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -