What substitutes xreadlines() in Python 3?

前端 未结 2 925
终归单人心
终归单人心 2021-01-02 03:09

In Python 2, file objects had an xreadlines() method which returned an iterator that would read the file one line at a time. In Python 3, the xreadlines() method no longer e

2条回答
  •  渐次进展
    2021-01-02 03:45

    how about this (generator expression):

    >>> f = open("r2h_jvs")
    >>> h = (x for x in f)
    >>> type(h)
    `
    

提交回复
热议问题