encoding
반응형
-
UnicodeEncodeError: 'ascii' codec can't encode characters개발Tip 2022. 3. 6. 00:41
기존 yaml 파일의 코드를 수정하기 위해 write를 시도해봤더니 아래와 같은 에러가 나왔다: File "/data/airflow/../delete_serviceKey_dag.py", line 45, in get_client_names outfile.write('\\n\\n\\n'.join(new_clients)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 449-453: ordinal not in range(128) =>file을 열고 작성할 때 open과 write 둘다 encoding이 필요하다 with open('/data/airflow/G2-CONF/clients.yml', encoding="utf-8") as ..