728x90
반응형
open() got an unexpected keyword argument 'encoding'
Json파일을 open해서 load하는 과정에서 encoding에러가 나길래, open함수 인자로 encoding 옵션을 넣어주었더니 상단과 같은 에러가 발생했다.
왜 없어진건진 모르겠지만 기존 open함수에 인자로 넣어주던 인코딩 옵션이 python 3.9로 업그레이드 되면서 사라졌다고 한다.
python을 3.8로 다운그레이드 하거나, 아니면 아래 방법으로 변경할 수는 있다고 한다.
def loads(txt):
txt = txt.encode("utf-8")
value = json.loads(txt)
return value
728x90
반응형
'사소한 Tip . 오류 해결법 > python' 카테고리의 다른 글
[python/PIL] image to pdf convert (0) | 2023.10.17 |
---|---|
[PIL] 투명한 이미지 만들기(글자만 남기기) / transparent image / remove background (2) | 2023.10.11 |
[python] 클래스 별 랜덤 컬러 정의 (0) | 2023.08.23 |
[streamlit] OSError: [Errno 28] inotify watch limit reached (0) | 2023.08.17 |
[python] random.sample with ordering(랜덤 추출하면서 순서 유지) (0) | 2023.08.04 |