【发布时间】:2013-10-04 23:33:26
【问题描述】:
我正在努力完成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: coercing to Unicode: need string or buffer, list found 但我不确定我的文件如何是一个列表而不是字符串。
【问题讨论】: