Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:u 30': 0.07; 'string': 0.09; 'ascii': 0.09; 'newline': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; '255': 0.16; 'hex': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'translators': 0.16; 'fix': 0.17; 'wrote:': 0.18; '>>>': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'header:X-Complaints-To:1': 0.27; 'getting': 0.31; 'lines': 0.31; '"",': 0.31; 'ball': 0.31; 'strip': 0.31; 'file': 0.32; '(most': 0.33; 'could': 0.34; 'skip:s 30': 0.35; 'convert': 0.35; 'but': 0.35; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 'email addr:gmail.com': 0.63; 'line,': 0.68; 'online': 0.71 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Odd-length string Date: Sun, 06 Oct 2013 16:31:11 +0200 Organization: None References: <0f1b6cd6-3025-4bdc-8f80-73a51a7ed241@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p50849e31.dip0.t-ipconnect.de User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381069884 news.xs4all.nl 15968 [2001:888:2000:d::a6]:57525 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56259 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 "", line 1, in binascii.Error: Odd-length string >>> unhexlify(tulemus.rstrip(b"\n")) b'whatever'