Q:

Python string to integer value

I'd like to know how to convert strings in Python to their corresponding integer values, like so:
>>>print WhateverFunctionDoesThis('\x41\x42') 
>>>16706
I've searched around but haven't been able to find an easy way to do this. 
Thank you.

A:

>>> import struct
>>> struct.unpack(">h",'\x41\x42')
(16706,)
>>> struct.unpack(">h",'\x41\x42')[0]
16706

For other format chars see the documentation

