以下の内容はhttps://maitakeramen.hatenablog.com/entry/2018/12/26/154739より取得しました。


【python】TypeError: 'encoding' is an invalid keyword argument for this function

Linuxubuntuでの話です。
python3を使うつもりの人が対象です。

ファイル入出力でエラー

with open(filename, encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function

python2を使っていないか?

open関数でこの書き方でエンコーディングを指定に対応しているのはpython3だぞ

バージョンを確認しよう

python --version

これだと、

Python 2.7.12

って出るんだなぁ!!!!
python2なんだなぁあああ!!!

python3 で実行したいなら、こうだ!

python3 [ファイル名]

罠だよなぁあああ




以上の内容はhttps://maitakeramen.hatenablog.com/entry/2018/12/26/154739より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14