module: zipfile.writestr - line endings issue
towers
damondolby at googlemail.com
Wed Aug 15 04:25:22 EDT 2007
> > Please don't top post.
>
> > The problem is with how you are opening the file. You need to open in
> > binary mode if you wish to read your file unaltered. Also, file() is
> > preferred over open() these days I think. Use:
>
> > dfile = file('test.csv', 'rb')
>
> From Python 2.5 library documentation.
>
> <quote>
> When opening a file, it's preferable to use `open()' instead of
> invoking this constructor directly. `file' is more suited to type
> testing (for example, writing `isinstance(f, file)').
> </quote>
>
> Python documentation seem to recommend using open(). I personally prefer
> to use open, just because python open has same signature as POSIX open,
> even beginner programmers can understand the intent of the code clearly.
>
> Kolla
Opening in binary mode solves the issue. Thanks very much for the help.
More information about the Python-list
mailing list