String --> int

Romain Guy romain.guy at jext.org
Thu Jun 21 07:49:20 EDT 2001


Sorry but:

405_DivX.avi framerate is
Traceback (most recent call last):
  File "aviFps.py", line 51, in ?
    print sys.argv[1], "framerate is", getAVI
  File "aviFps.py", line 21, in getAVIFrameRa
    movieScale = int(fsock.read(4))
ValueError: invalid literal for int(): ?


--
Romain "Java Swinguer !" Guy
romain.guy at jext.org
www.jext.org

"Now, don't you worry. The saucers are up there. The graveyard is out there.
But I'll be locked up safely in there."
- Paula Trent, Plan 9 From Outer Space
"Tyler Eaves" <tyler at tylereaves.com> a écrit dans le message news:
ftp3jtko5bv69qhir1uvafohtf1skk3odp at 4ax.com...
> On Thu, 21 Jun 2001 13:17:55 +0200, "Romain Guy" <romain.guy at jext.org>
> wrote:
>
> >    Assuming fsock is a File objet, when I do:
> >var = fsock.read(4)
> >I get a String. I'd like to convert it into an integer. I haven't found
any
> >method for this so I built this one:
> >
> >def _buildInteger(bytes):
> >  if len(bytes) != 4:
> >    return -1
> >  else:
> >    return ord(bytes[0]) | ord(bytes[1]) << 8 | ord(bytes[2]) << 16 |
> >ord(bytes[3]) << 24
> >
> >It works perfectly but I'd like to use one internal to Python if
possible...
>
> I hare to tell ya this, but try int(strg)





More information about the Python-list mailing list