python error 'cp949' codec can't encode character

python 실행 에러 
'cp949' codec can't encode character '\u2b50' in position 169: illegal multibyte sequence

1. 원인
파일 읽기 옵션\의 문제
 f = open("i:/Share/pusan.txt", 'w')

 data = data + link[0].text + ' '
              if len(data) > 1000:
                        f.write(data)


2.해결
파일의 읽기 쓰기 오류로서 파일 쓰기 옵션에 utf-8을 붙여 줍니다.
f = open("i:/Share/pusan.txt", 'w', -1, "utf-8")

댓글

이 블로그의 인기 게시물

error You have $NVM_DIR set to "/root/.nvm", but that directory does not exist. Check your profile files and environment.

linux mint install xrdp

centos 6.x yum update problem making ssl connection