2011-06-05 67 views

回答

4

雖然在Python 3.x中沒有file類型,但io模塊中的各種類型替換舊的file類型still support f.readline() and f.readlines()。但實際上並不需要這些方法,因爲它們可以被next(f)list(f)替代。

2

這是用於Python 3.2的the documentation(以及教程)。 readlinereadlines仍然是Python的一部分。

1

不,他們沒有。

f = open("file", "r") 
f.readlines() 

正在爲我工​​作,Python 3.2。

編輯:它會產生一個io對象(不是文件)。

0

我也有問題。但是,當我包括一個

import readline 

在我的腳本的頂部,一切工作正常。看來它現在必須明確導入。

+0

'ImportError:No module named'readline' ' – Ooker 2015-08-16 14:37:17