2

I'm downloading files over HTTPS, I request the files through urllib2.Request and they come back as a socket._fileobject. I'd ideally like to stream this to file to avoid loading it into memory but I'm not sure how to do this.

My problem is if I call .read() on the object it only returns all the data up to the first NUL character and doesn't read the whole file. How can I solve this?

The NUL character comes down as \x00 if that's any help, not sure what encoding that is

4

1 回答 1

1

我发现问题是我在 PyScripter 中运行代码,并且内置的 python 解释器终止了输出中的 NUL 字节。所以我的代码没有问题,如果我在 PyScripter 之外运行它,一切正常。现在运行 Wing IDE,永不回头 :)

于 2011-10-17T08:31:32.253 回答