Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28197
| References | <CA+YdQ_66ap1tQCRibdkntGvHqE1sp+Nv_kK2iiKh50GoAa=K6Q@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-08-31 20:40 -0600 |
| Subject | Re: how to get character hex number? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17.1346467264.27098.python-list@python.org> (permalink) |
On Fri, Aug 31, 2012 at 8:21 PM, contro opinion <contropinion@gmail.com> 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?
>>> ''.join("%02x" % ord(b) for b in u"english".encode("ascii"))
'656e676c697368'
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: how to get character hex number? Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-31 20:40 -0600
csiph-web