#!/usr/bin/env python
# -*- coding:utf-8 -*-
file="/usr/local/test"
alist = ["hello
","python
"]
generator = ("{} {}
".format(i,i+1) for i in range(9))
#写入文件
with open(file,"w") as fd_out:
fd_out.writelines(alist)
fd_out.writelines(generator)
#读文件
with open(file,"r") as fd_in:
for line in fd_in:
print(line.strip())