Quickie: converting r"\x2019" to int

Just just at xs4all.nl
Thu Apr 6 14:00:13 EDT 2006


In article <4435501d$1_2 at newspeer2.tds.net>,
 Kent Johnson <kent at kentsjohnson.com> wrote:

> Robin Haswell wrote:
> > Hey guys. This should just be a quickie: I can't figure out how to convert
> > r"\x2019" to an int - could someone give me a hand please?
> 
> Is this what you mean?
> In [9]: int(r'\x2019'[2:], 16)
> Out[9]: 8217
> 
> or maybe you meant this:
> In [6]: ord(u'\u2019')
> Out[6]: 8217

Or even:

  >>> import struct 
  >>> struct.unpack("q", "\0\0"+ r'\x2019')[0]
  101671307850041L
  >>> 

Who knows :)

Just



More information about the Python-list mailing list