Post

반응형

가끔씩 c949 에러가뜬다.

UnicodeEncodeError: 'cp949' codec can't encode character '\u2b50' in position 48: illegal multibyte sequence

    out_file.write(line)
UnicodeEncodeError: 'cp949' codec can't encode character '\u2b50' in position 48: illegal multibyte sequence

내 경험상 c949에러는 눈에 보이지 않는데 존재하는 글자가 있어서 읽을 수 없는 경우에 에러가 났다.

이럴 때 대체 어디 줄에서 글자 에러가 나는지 막막하다. 이땐 line을 print 해주면 쉽게 에러가 나는 부분을 알 수있다.

    for line in file:
        print(line)

나 같은 경우엔 그... 별 문자열 말고 별 이모티콘;;;때문에 문제가 발생했다;;;삭제하니까 깔끔하게 파일읽기 완료

 

반응형

Post

반응형

inconsistent use of tabs and spaces in indentation in Python

inconsistent use of tabs and spaces in indentation in Python 에러는 탭이 아니라 띄어쓰기를 했을 경우에 발생한다. 겉보기에는 똑같지만 탭과 띄어쓰기는 다르니까 확인해보고 띄어쓰기나 탭을 지웠다가 다시 탭을 해보면 된다.

    print(line.text)
          ^^^^^^^^^
AttributeError: 'str' object has no attribute 'text'

AttributeError: 'str' object has no attribute 'text'

이건 line 안에 text가 없어서 나는 에러이다. 그냥 line을 써주면 된다.

반응형
▲ top