[Numpy-discussion] String to integer array of ASCII values

Charles R Harris charlesr.harris@gmail....
Thu Jul 23 11:07:19 CDT 2009


On Thu, Jul 23, 2009 at 9:50 AM, Peter <
numpy-discussion@maubp.freeserve.co.uk> wrote:

> On Thu, Jul 23, 2009 at 3:54 PM, Charles R
> Harris<charlesr.harris@gmail.com> wrote:
> >
> > Would something like
> >
> > In [2]: array("ABCDEF", 'c').view(uint8)
> > Out[2]: array([65, 66, 67, 68, 69, 70], dtype=uint8)
> >
> > work for you?
>
> Yes, that also looks good. I guess I have a couple of options to
> benchmark now :)
>

One more:

 In [1]: fromstring("ABCDEF", dtype=uint8)
Out[1]: array([65, 66, 67, 68, 69, 70], dtype=uint8)

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090723/1cb72b2c/attachment.html 


More information about the NumPy-Discussion mailing list