2013-10-06 3 views
1

전문가!유니 코드 이스케이프 오류

Twython으로 트위터 클라이언트를 만들려고합니다. 지금은 대화 형 인터프리터에서 명령을 검색합니다. 사진을 업로드 테스트에서

, 난이 문자열을 전달 :

"tweet photo: 'tweeted from python test' + path: 'C:\Users\akhya_000\Pictures\My Pictures\Bing.png" 

을하지만 난 그것을 무효 발견하고이 오류가 발생했습니다 :

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 51-52: truncated \UXXXXXXXX escape 
이 가

누군가가 나를 도울 수, 무슨 문제 그 끈? 문제를 해결하려면 어떻게해야합니까?

답변

1

파이썬이 \U을보고이를 Unicode escape sequence으로 해석하기 때문에 백 슬래시를 이스케이프 처리하거나 원시 문자열을 사용하려고합니다.

이스케이프는 다음과 같다 : 파이썬은 이스케이프 시퀀스를 무시합니다

raw string
"tweet photo: 'tweeted from python test' + path: 'C:\\Users\\akhya_000\\Pictures\\My Pictures\\Bing.png" 

은, 다음과 같습니다

r"tweet photo: 'tweeted from python test' + path: 'C:\Users\akhya_000\Pictures\My Pictures\Bing.png" 
+0

감사합니다! 나는 무엇이 잘못되었는지 이해합니다. –

관련 문제