在python中打开文件(命令打开)

时间:2014-03-05 17:58:47

标签: python file-io

我正在做一个在python中编程的在线课程。我必须在列表中读取文件的内容。我编写了下面的代码。该程序有效,但当我将我的工作提交到网站时,它会给我以下信息。你知道会出现什么问题吗?谢谢

def read_words(words_file):
    """ (file open for reading) -> list of str
    Return a list of all words (with newlines removed) from open file
    words_file.

    Precondition: Each line of the file contains a word in uppercase characters
    from the standard English alphabet.
    """

    words_file=open(words_file)
    los=[]
    for line in words_file:
        if '\n' in line:
            line=line[:len(line)-1]
        los.append(line)
    return (los)

方法描述: 无

消息: 错误:DisabledBuiltinError

不允许调用open内置。

0 个答案:

没有答案