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
.
精彩评论