Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56259

Re: Odd-length string

From Peter Otten <__peter__@web.de>
Subject Re: Odd-length string
Date 2013-10-06 16:31 +0200
Organization None
References <0f1b6cd6-3025-4bdc-8f80-73a51a7ed241@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.783.1381069884.18130.python-list@python.org> (permalink)

Show all headers | View raw


markotaht@gmail.com wrote:

> print("Key-" + str(võti) + ": " + str(unhexlify("".join(tulemus))))
> 
> IM getting this error on this line. This is the print line of a decryption
> program. I wanti it to convert the tulemus which is in HEX to ASCII so i
> could read it. I could use online translators for the line, but since i
> have 255 lines of the HEX codes, it would be higly unefficient.
> 
> How to i fix the Oddlenght string?

My crystal ball says: strip off the newline byte:

>>> unhexlify(tulemus)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
binascii.Error: Odd-length string
>>> unhexlify(tulemus.rstrip(b"\n"))
b'whatever'

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Odd-length string markotaht@gmail.com - 2013-10-06 06:10 -0700
  Re: Odd-length string Roy Smith <roy@panix.com> - 2013-10-06 09:46 -0400
  Re: Odd-length string Peter Otten <__peter__@web.de> - 2013-10-06 16:31 +0200
  Re: Odd-length string markotaht@gmail.com - 2013-10-06 07:37 -0700
    Re: Odd-length string Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 15:56 +0100
    Re: Odd-length string Terry Reedy <tjreedy@udel.edu> - 2013-10-06 15:50 -0400
    Re: Odd-length string Piet van Oostrum <piet@vanoostrum.org> - 2013-10-06 20:59 -0400

csiph-web