In PHP
I will do it like this:
$res = unpack('C*', "string");
And $res
variable will be an array of size 6:
Array ( [1] => 115 [2] => 116 [3] => 114 [4] => 105 [5] => 110 [6] => 103 )
I want to do the same trick in Python
. I tried this:
>>> from struct import unpack
>>> unpack("s","string")
But in this case I get an error:
struct.error: unpack requires a string argument of length 1
I just wonder - why of length 1 if "s" format stands for string? And how can I implement the same thing, like in PHP?