列表理解提示
List comprehensions tip
有没有更优雅的写法?:
q = []
for line in lines:
date = line.split(",", 1)
q.append(date[0])
我正在尝试理解列表理解。
任何帮助将不胜感激
q = [line.split(",", 1)[0] for line in lines]
有没有更优雅的写法?:
q = []
for line in lines:
date = line.split(",", 1)
q.append(date[0])
我正在尝试理解列表理解。
任何帮助将不胜感激
q = [line.split(",", 1)[0] for line in lines]