[Tutor] reading a string into an array

Kent Johnson kent37 at tds.net
Sun Jun 1 13:22:50 CEST 2008


On Sun, Jun 1, 2008 at 7:03 AM, bob gailer <bgailer at gmail.com> wrote:

> Even more concise and possibly faster:
>
> data = open('out.out').read().replace('\n', '\\').split('\\')

Or use re.split() to split without the replace:
  import re
  data = open('out.out').read()
  data = re.split(r'[\n\\]', data)

Kent


More information about the Tutor mailing list