'2.6.5(R265:79063,2010年4月16日,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,
這將打印這樣的O/p:
$ ./filetest.py
This is a line
[email protected]:~/pythonpractice$
我很奇怪,爲什麼不及時去之後的換行符「這是一條線」印? 因爲cat filestest
給出了這樣的:
$ cat filetest
This is a [email protected]:~/pythonpractice$
嘗試總是使用「與」當你使用文件,這是更清潔。 –