갑자기 내리는 비 2021. 5. 11. 16:44

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

 

윈도우에서 경로를 찾을 때 사용하는 \ 문자가 유니코드로 읽혀서 생기는 오류입니다.

 

즉, \를 /로 바꿔주면 됩니다.( \\로 바꿔줘도 됩니다. )

 

f = open('C:\Users\Administrator\Desktop\test.txt','w')

-- > f = open('C:/Users/Administrator/Desktop/test.txt','w')

또는

-- > f = open('C:\\Users\\Administrator\\Desktop\\test.txt','w')