Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28198 > unrolled thread

Re: how to get character hex number?

Started byTim Chase <python.list@tim.thechases.com>
First post2012-08-31 21:42 -0500
Last post2012-08-31 21:42 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: how to get character hex number? Tim Chase <python.list@tim.thechases.com> - 2012-08-31 21:42 -0500

#28198 — Re: how to get character hex number?

FromTim Chase <python.list@tim.thechases.com>
Date2012-08-31 21:42 -0500
SubjectRe: how to get character hex number?
Message-ID<mailman.18.1346467309.27098.python-list@python.org>
On 08/31/12 21:21, contro opinion wrote:
>>>> for i in "english" :
> ...   print(hex((ord(i))))
> ...
> 0x65
> 0x6e
> 0x67
> 0x6c
> 0x69
> 0x73
> 0x68
>>>> u"english".encode("utf-8")
> 'english'
>>>> u"english".encode("ascii")
> 'english'
> 
> how can i get 656e676c697368 in encode method?

At least in 2.x, you can do:

>>> u"english".encode("hex")
'656e676c697368'

-tkc


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web