Monday 15 September 2014

python - List of ints to string -



python - List of ints to string -

i have list of ints:

(83, 105, 101, 109, 101, 110, 115)

which believe codes siemens.

how can convert list string in pythonic way?

i know can individual chars chr(x) , concatenate them doesn't seem best way.

using bytes (or str) , bytearray:

>>> bytes(bytearray((83, 105, 101, 109, 101, 110, 115))) 'siemens'

in python 3.x:

>>> bytes((83, 105, 101, 109, 101, 110, 115)).decode() 'siemens'

python string char int

No comments:

Post a Comment