#! rnews 1066
Newsgroups: comp.lang.python
Path: 
news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!attws2!ip.att.net!NetNews1!xyzzy!nntp
From: Harry George <[EMAIL PROTECTED]>
Subject: Re: hex string into binary format?
X-Nntp-Posting-Host: cola2.ca.boeing.com
Content-Type: text/plain; charset=us-ascii
Message-ID: <[EMAIL PROTECTED]>
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3
Lines: 28
Sender: [EMAIL PROTECTED]
Organization: The Boeing Company
References: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Date: Thu, 31 Mar 2005 14:58:03 GMT
Xref: news.xs4all.nl comp.lang.python:370100

"Tertius Cronje" <[EMAIL PROTECTED]> writes:

> Hi, 
> 
> How do I get a hexvalued string to a format recognized for binary
> calculation?
> 
> 
> import binascii
> s1 = '1C46BE3D9F6AA820'
> s2 = '8667B5236D89CD46'
> 
> i1 = binascii.unhexlify(s1)
> i2 = binascii.unhexlify(s2)
> x = i1 ^i2
> 
>       TypeError: unsupported operand type(s) for ^: 'str' and 'str'
> 
> Many TIA
> T

i1=int(s1,16)
i2=int(s2,16)

-- 
[EMAIL PROTECTED]
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to