<p>How do I convert a hex string to an integer?</p>
<pre><code>&quot;0xffff&quot;   ⟶   65535
&quot;ffff&quot;     ⟶   65535
</code></pre>

```
int(hexstring, 16)
```
does the trick, and works with and without the 0x prefix:
```
```
>>> int("a", 16)
10
>>> int("0xa", 16)
10
```
```