0
私はPythonを初めて学びました。Python:TypeError:Unicodeに強制する:必要な文字列またはバッファー、モジュールが見つかりました
私はファイルの1つを入力していますが、私はpythonを使ってコンソールにテキストを印刷したいと思います。
# This will take the file as input
import fileinput
for line in fileinput.input():
print "The file name you provided is " + fileinput.filename()
#file of = open(fileinput, "r", 0)
with open(fileinput,'r') as myfile:
data=myfile.read()
print "This is your actual data \n\n" + data
私が経験してるのエラーは次のとおりです。
TypeError: coercing to Unicode: need string or buffer, module found
いずれかが、このしてくださいに私を助けてもらえます。
ファイルをまったく開く必要はありません。 'fileinput'モジュールが実際に何をするのかを見てください。 – kindall