'2.6.5 (r265:79063, Apr 16 2010, 13:57:41) \n[GCC 4.4.3]'
我有这个版本
#! /usr/bin/env python
f = open('filetest', 'w')
f.write("This is a line")
f.close()
f = open('filetest', 'r')
for i in f.readlines():
print i,
这将打印输出如下:
$ ./filetest.py
This is a line
abc@abc-ubuntu:~/pythonpractice$
我想知道为什么在打印“This is a line”后会换行?
因为运行cat filestest
会得到以下结果:
$ cat filetest
This is a lineabc@abc-ubuntu:~/pythonpractice$