IT業界のすみっこ暮らし

ふと気がついたときの記録



Python:utf8でテキストファイル作成

Python:utf8でテキストファイル作成

cleantext = 'あああ'
character_encoding = 'utf8'
with io.open('text1.txt', 'w', encoding=character_encoding) as file:
    file.write(cleantext)

encodingを指定しないまま日本語を入れるとまたエンコードエラーになる。





プライバシーポリシー