我用 python 写了一个原始代码,我怎样才能让它看起来更像一个 python 结构,
我还没有为每个函数创建类和对象,我想返回而不是打印
我怎样才能明智地分离功能并在最后返回?
with open(r'features.csv', 'r') as f:
checker = lambda i: bool(i and i.strip())
reader = csv.reader(f)
header = next(reader)
folders = next(
{
header[0]: [row[0]],
'Feature Name': list(filter(checker, row[:1])),
'Child folder': list(filter(checker, row[1:]))
} for row in reader
)
foldersinlist = list(folders.values())
lists = sum(foldersinlist, [])
print(lists)
有什么想法吗?
九州编程
相关分类