Split string data have ,
Hi All Python 2.6.2 on AIX 5.3 How to using split o y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p -- http://mail.python.org/mailman/listinfo/python-list
Re: Split string data have ,
On Tue, 29 moonhkt moon...@gmail.com wrote: y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p The csv module should handle this nicely: import csv y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b r = csv.reader([y]) print r.next() ['abc.p,zip.p', 'a', 'b'] -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Split string data have ,
On Jan 29, 2013 9:05 AM, moonhkt moon...@gmail.com wrote: Hi All Python 2.6.2 on AIX 5.3 How to using split o y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p Try the csv module or the shlex module. -- http://mail.python.org/mailman/listinfo/python-list
Re: Split string data have ,
On Jan 30, 1:08 am, Chris Rebert c...@rebertia.com wrote: On Jan 29, 2013 9:05 AM, moonhkt moon...@gmail.com wrote: Hi All Python 2.6.2 on AIX 5.3 How to using split o y = 'abc.p,zip.p,a,b' print y abc.p,zip.p,a,b k= y.split(,) print k[0] abc.p Need Result, First element is abc.p,zip.p Try the csv module or the shlex module. Thank a lot, Using csv is good for me. -- http://mail.python.org/mailman/listinfo/python-list