'''로 주석으로 만들었는데 왜 주석을 지우지 않으면 유니코드오류가 왜 나는지 모르겠어여
조회수 274회
'''
f = open(r"C:\Users\ocwot\Desktop\파이썬 연습\example.txt",'a+' ,encoding='utf-8')
f.write('Deae,') # 데이터 추가
f.seek(0)
print(f.read())
f.close()
'''
f = open(r"C:\Users\ocwot\Desktop\파이썬 연습\example.txt", encoding='utf-8')
print(f.read())
txt 파일에는
Deae,Deae,Deae,Deae,DeaeDeae,
이와같은 글이 들어가있고
'''
안에 있는 코드는 주석처리 되서 영향을 주지 않는걸로 알고있는데
주석의 내용을 지우면 오류없이 되고,
지우지 않으면
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 14-15: truncated \UXXXXXXXX escape
PS C:\Users\ocwot\Desktop\파이썬 연습>
이와 같이 오류가 납니다. 왜그런지 모르겠습니다.
댓글 입력