开发者

Port Python v2 function to v3

This v2 function gives a 开发者_如何学编程"NameError: global name 'file' is not defined" error when run in v3.

def from_file(filename, sep='\n'):  
    "Parse a file into a list of strings, separated by sep."  
    return file(filename).read().strip().split(sep)  

Could someone please provide a v3 version?


Change the file call to open.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜