📜  从文件中保存行 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:22.476000             🧑  作者: Mango

代码示例1
def get_data_from_text_file(file):

    # declare an empty list for the data
    data = []

    # get the data line-by-line using os.open()
    for line in open(file, encoding="utf8", errors='ignore'):
        # append each line of data to the list
        data += [ str(line) ]    
    # return the list of data
    return data