此 v2 函数在 v3 中运行时给出“NameError:全局名称‘file’未定义”错误。
def from_file(filename, sep='\n'):
"Parse a file into a list of strings, separated by sep."
return file(filename).read().strip().split(sep)
有人可以提供 v3 版本吗?
请您参考如下方法:
将 file 调用更改为 open。
