Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28197 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2012-08-31 20:40 -0600 |
| Last post | 2012-08-31 20:40 -0600 |
| 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.
Re: how to get character hex number? Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-31 20:40 -0600
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2012-08-31 20:40 -0600 |
| Subject | Re: how to get character hex number? |
| Message-ID | <mailman.17.1346467264.27098.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web