def skip_header(r):
# '''跳过 文件 r 的头,'''
line = r.readline()
line = r.readline()
while line.startswith( ' # ' ) #两次使用line = r.readline(),如果 以 '#' 开头,则跳过这行
line = r.readline()
return line
def process_file(r):
#读取文件除 以 ‘#’ 注释的文件内容
line = skip_header(r).strip()
print line
for line in r:
line = line.strip()
print line
if __name__ == "__main__":
input_file = open(sys.argv[1], 'r')
process_file(input_file)
input_file.close()