Converting a hex string to a number

Simon.Foster at smiths-aerospace.com Simon.Foster at smiths-aerospace.com
Tue Jul 9 08:43:14 EDT 2002


Tal said:

>Hello,
> I am trying to convert a hex string (for example: "0x12345678") to a
>number (0x12345678 or just 12345678).
> Can you help me please?
>Thanks, Tal.

eval!

C:\WINNT\Profiles\syf\Desktop>python
Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> string = '0x12345678'
>>> eval( string )
305419896
>>>





More information about the Python-list mailing list