Learn Python the Hard Wayを進めており、演習16の追加のクレジットに固執しています。メインの演習16を使用して作成したファイルを読み込もうとしています。作成したコードは次のとおりです。
# pylint: disable-msg=C0103
""" This script reads and prints a file set from the argv """
from sys import argv
filename = argv
txt = open(filename)
print txt.read()
私が読み込もうとしているファイルは次のとおりです。
Derp Derp
Reading this file
Will it work?
次のエラーが表示されます:TypeError:Unicodeへの強制:文字列またはバッファが必要です。リストが見つかりましたが、ファイルが文字列ではなくリストであるかどうかわかりません。