Python

[Python] UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

언킴 2023. 7. 3. 11:20
반응형

pickle 파일을 사용할 때나 txt 파일을 불러올 때 발생하는 오류다. byte로 받아오라는 에러 코드라 아래 코드로 변경하면 에러가 발생하지 않는다.

 

path = 'base directory'

with open(path, 'r') as f:
    files = pickle.load(f)
    
# 'r' -> 'rb'
with open(path, 'rb') as f:
    files = pickle.load(f)