Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44442
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fabiosantosart@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'anyway.': 0.05; 'f.close()': 0.09; 'subject:module': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'windows': 0.15; 'advance!': 0.16; 'chunks': 0.16; 'hex': 0.16; 'loop.': 0.16; 'looping': 0.16; 'once.': 0.16; 'subject:File': 0.16; 'subject:issue': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'starts': 0.20; 'memory': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'this?': 0.23; 'processor': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'file': 0.32; 'run': 0.32; 'url:python': 0.33; 'skip:# 10': 0.33; 'maybe': 0.34; 'problem': 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'right?': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'too': 0.37; 'received:209': 0.37; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'thank': 0.38; 'itself': 0.39; 'url:mail': 0.40; 'tell': 0.60; 'become': 0.64; 'taking': 0.65; 'to:addr:gmail.com': 0.65; '8bit%:60': 0.84; 'trouble.': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=++tHec7bKZQpiX0MqU5sZt0agxG15J1YDJXq5QdwQ/c=; b=mHTMt7E13yr1CDQj1GZz08A+W773mUiGj/4uKosOidvJXHFNMGJT4nHoSWwvuWRanw Ttp4gMe8pHPBoMV9OiFayq0rp3aB27Nr/0PtMvFTAOeCf/7lyFYi8SsKsU8Rrs1XO1cU KRAiG3WGxQCsHKUrgyMKDzTnHYgw/w7iCs3TGy6cEuxZ8Et1vUZU9lM+seS9XFk8h0Gb jjGtSAZF55v02pVqptrwgm8pZeOsDk/NssdUkdrdq+RlKk5t67F33Eac9JU0+jT2XKcu Z0kyWkYx8TaJRp+XWQAzonZYxEDxpzxyzNF9LFpF5k6lpn1YBmipZPsj2kaBKPTnA5Nr 05zw== |
| MIME-Version | 1.0 |
| X-Received | by 10.49.104.145 with SMTP id ge17mr38163599qeb.59.1367056568451; Sat, 27 Apr 2013 02:56:08 -0700 (PDT) |
| In-Reply-To | <be399492-2c63-40f6-840d-ccefa8f78218@googlegroups.com> |
| References | <9b5795ab-baec-4c0a-a3b4-1075cffc8744@googlegroups.com> <be399492-2c63-40f6-840d-ccefa8f78218@googlegroups.com> |
| Date | Sat, 27 Apr 2013 10:56:08 +0100 |
| Subject | Re: File Read issue by using module binascii |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| To | Jimmie He <jimmie.he@gmail.com> |
| Content-Type | multipart/alternative; boundary=047d7b5d8fc526871404db54a9ac |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1121.1367056577.3114.python-list@python.org> (permalink) |
| Lines | 117 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1367056577 news.xs4all.nl 15916 [2001:888:2000:d::a6]:40388 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44442 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
It may be that you are printing too much data at once. 100k is a bit too
much to have in memory but it should run anyway. But your console may be
having trouble. Try looping over small chunks of the file and printing them
one at a time. Use a while loop. I do know that in windows the console is
not very efficient at printing so when I print too much data the console
itself starts taking up a lot of processor time.
On 27 Apr 2013 05:28, "Jimmie He" <jimmie.he@gmail.com> wrote:
> when I commet the line of "print('bin: ',bsstr,type(bsstr)) ",it can be
> run,so maybe the problem is the memory allocate of so long strings......Am
> I right?
>
> 在 2013年4月27日星期六UTC+8上午11时57分45秒,Jimmie He写道:
> > When I run the readbmp on an example.bmp(about 100k),the Shell is become
> to "No respose",when I change f.read() to f.read(1000),it is ok,could
> someone tell me the excat reason for this?
> >
> > Thank you in advance!
> >
> >
> >
> > Python Code as below!!
> >
> >
> >
> > import binascii
> >
> >
> >
> > def read_bmp():
> >
> > f = open('example.bmp','rb')
> >
> > rawdata = f.read() #f.read(1000) is ok
> >
> > hexstr = binascii.b2a_hex(rawdata) #Get an HEX number
> >
> > bsstr = bin (int(hexstr,16))[2:]
> >
> > f.close()
> >
> > print('bin: ',bsstr,type(bsstr))
> >
> > return
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-26 20:57 -0700
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-26 21:22 -0700
Re: File Read issue by using module binascii Fábio Santos <fabiosantosart@gmail.com> - 2013-04-27 10:56 +0100
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-27 03:42 -0700
Re: File Read issue by using module binascii Peter Otten <__peter__@web.de> - 2013-04-27 12:57 +0200
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-27 04:23 -0700
Re: File Read issue by using module binascii Fábio Santos <fabiosantosart@gmail.com> - 2013-04-27 12:40 +0100
Re: File Read issue by using module binascii Peter Otten <__peter__@web.de> - 2013-04-27 14:01 +0200
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-27 05:46 -0700
Re: File Read issue by using module binascii Tim Roberts <timr@probo.com> - 2013-04-27 21:34 -0700
Re: File Read issue by using module binascii Peter Otten <__peter__@web.de> - 2013-04-28 09:42 +0200
Re: File Read issue by using module binascii jt@toerring.de (Jens Thoms Toerring) - 2013-04-28 12:04 +0000
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-28 06:32 -0700
csiph-web