标签: python list list-comprehension
有更优雅的方式来写这个吗?:
q = [] for line in lines: date = line.split(",", 1) q.append(date[0])
我试图理解列表理解。
任何帮助都将非常感激
答案 0 :(得分:3)
q = [line.split(",", 1)[0] for line in lines]