2012-08-11 20 views

回答

3
with open('mylist.txt') as f: 
    for line in f: 
     print line 
0
with open('/home/acer/Desktop/mylist.txt') as f: #path to the file 
    print f.read() 

瞭解更多有關文件read/writehere

+1

請注意這種方法適用於大型文件(http://docs.python.org/tutorial/inputoutput.html#methods-of-file-objects) – 2012-08-11 06:35:14

相關問題