0
我試圖打印n行並拿走每行打印的前4個字符,但第一行不會出現。爲什麼文件的第一行不打印?
代碼:
def saveLine(ifile,ofile,n):
'''Prints n number of lines with first 4 spaces gone'''
infile = open(ifile, 'r')
outfile = open(ofile, 'w')
line = infile.readline()
lines = infile.readlines()
for i in range(n - 1):
line = lines[i]
outfile.write(line[4:])
infile.close()
outfile.close()
@Barmar我應該只刪除那部分呢? –