>>y
[116, 114, 121, 32, 116, 104, 105, 115]
>>z=''.join(chr(yi) for yi in y) z
'try this'
What is an efficient way to do this if y is much longer?
(A numpy solution is fine.)
Thanks,
Alan Isaac 4 1071
David Isaac wrote:
>>>y
[116, 114, 121, 32, 116, 104, 105, 115]
>>>z=''.join(chr(yi) for yi in y) z
'try this'
What is an efficient way to do this if y is much longer?
(A numpy solution is fine.)
With numpy, something like the following:
>>from numpy import * y = [116, 114, 121, 32, 116, 104, 105, 115] a = array(y, dtype=uint8) z = a.tostring() z
'try this'
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
"David Isaac" <ai*****@verizon.netwrites:
>y
[116, 114, 121, 32, 116, 104, 105, 115]
>z=''.join(chr(yi) for yi in y) z
'try this'
What is an efficient way to do this if y is much longer?
import array
z = array.array('B',y).tostring()
David Isaac wrote:
>>>y
[116, 114, 121, 32, 116, 104, 105, 115]
>>>z=''.join(chr(yi) for yi in y) z
'try this'
What is an efficient way to do this if y is much longer?
(A numpy solution is fine.)
Here's another numpy solution just for fun:
import numpy
z = numpy.array(y,dtype='u1').view('S%d' % len(y))[0]
-Travis
Robert Kern wrote:
>>from numpy import * y = [116, 114, 121, 32, 116, 104, 105, 115] a = array(y, dtype=uint8) z = a.tostring() z
'try this'
Very nice! Thanks also to Paul and Travis!
Alan Isaac This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Lilja |
last post by:
Hello, I'm working on my C++ homework and I have a question about the
following function.
It's part of my code the handles command line arguments....
|
by: Stewart Allen |
last post by:
Hi there
I'm trying to find part serial numbers between 2 numbers. The user selects a
part number from a combo box and then enters a range of...
|
by: pesso |
last post by:
I have a string that contains the following:
string s = "130,41,43,178,41,17,6,78,244,35,202,144,115";
They are comma separated byte numbers, and...
|
by: Sam Kong |
last post by:
Hello!
I wonder if there's a good way to make a function that calculates 2
big numbers (whole numbers) expressed as strings and return a result...
|
by: Tony WONG |
last post by:
i have a number of forms with fax numbers to come up into arrays and then
combine to string.
after that i design the flow
1. break the string to...
|
by: Ron |
last post by:
I want to write a program that will accept a number in a textbox for
example 23578 and then in a label will display the sum of the odd and
even...
|
by: lim4801 |
last post by:
I am currently in doing a program which is given by my tutor:
Contemplate that you are working for the phone company and want to sell "special"...
|
by: =?Utf-8?B?ZGg=?= |
last post by:
If there's bunch of hex numbers: 0xA6, 0xD9, 0x00, 0xAA, 0x00, and 0x62, how
to construct a string ("string" in C#) with those hex numbers?
...
|
by: Smokey Grindel |
last post by:
Alright so I have a string... that can be anything like this then have a
number like 102.34m, yes there is a m behind it to say "this is money", no...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
| |