728x90
반응형
파일 Open 하여 Write 중 에러가 발생했습니다.
f = open('wiki_data.txt','w')
f.write(data)
f.close()
다음과 같이 에러가 발생했습니다.
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
Input In [21], in <cell line: 16>()
13 f = open('wiki_data2.txt','w')
---> 16 f.write(data)
17 f.close()
UnicodeEncodeError: 'cp949' codec can't encode character '\u2013' in position 28602: illegal multibyte sequence
해결 방법
- Open 시 encoding='UTF-8' 옵션을 추가해 줍니다.
f = open('wiki_data.txt','w',encoding='UTF-8')
f.write(data)
f.close()
728x90
반응형
'프로그램' 카테고리의 다른 글
[파이썬] bz2 파일 text로 저장 하기 (0) | 2022.08.22 |
---|---|
[파이썬] 위키피디아(Wiki) 한글 자료 Dump (0) | 2022.08.22 |
[파이썬] nltk에서 에러(Resource punkt not found) (0) | 2022.08.22 |
[파이썬/법칙] 콜라츠 추측 (1) | 2022.08.21 |
[Tensorflow] 에러 (tensorflow Fail to find the dnn implementation) (0) | 2022.08.21 |
댓글