Python code
lnum = 0
with open('pit.txt', 'r') as fd:
for line in fd:
lnum += 1;
if (lnum >= 10) && (lnum <= 13):
print line
fd.close()
def eachlineof(filename):
''' 逐行读取给定的文本文件,返回行号、剔除末尾空字符的行内容 '''
with open(filename) as handle:
for lno, line in enumerate(handle):
yield lno+1, line.strip()
另外: 读写excel需要第三方类库,可以考虑下载安装xlrd, xlwt