[Tutor] printing files

Kent Johnson kent37 at tds.net
Thu Mar 26 22:49:29 CET 2009


On Thu, Mar 26, 2009 at 2:58 PM, ALAN GAULD <alan.gauld at btinternet.com> wrote:
> Use '\n'.join(handle[1:])
> It will create a string from your list with newline as separator.

The lines from readlines() include the newlines already.

> When i use the following
>
> print>>out, handle[1:]
>
> In the out file, it saves the lines as a list rather than as a string. How
> to avoid this.

use
  out.writelines(handle[1:])

Kent


More information about the Tutor mailing list