is there more simple way to do?

Peter Otten __peter__ at web.de
Wed Apr 9 06:48:43 EDT 2014


length power wrote:

> x='name,sex,birthday\n\nx1,male,1948/05/28\n\nx2,female,1952/03/27
> \n\nx3,female,1994/12/09'
> x.replace("\n\n","\n").splitlines()
> 
> is there more simple way to replace  `x.replace("\n\n","\n").splitlines()`
> ?

One alternative that ignores all empty lines is

[line for line in x.splitlines() if line]




More information about the Python-list mailing list