downloading files

Steve Holden steve at holdenweb.com
Fri Aug 3 22:27:05 EDT 2007


Ehsan wrote:
> On Aug 3, 10:10 pm, Steve Holden <st... at holdenweb.com> wrote:
[...]
>> I'm guessing there are binary files and you are running on Windows,
>> which is inserting a carriage return before ebery newline. Try
>>
>>         localFile = open(fileName, 'wb')
>>
>> to avoid thus behavior.
[...]
> thanx Steve
> It works but could you explain more what's wrong with just 'w'?
> 

Hmm, I thought I had. 'b' stand for 'binary', and the system sends out 
exactly the bytes you right. Without the 'b' it assumes you are handling 
text, so Windows "CR/LF" line endings are converted to "LF" or reading, 
and "LF" is converted to "CR/LF" on writing.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------



More information about the Python-list mailing list