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


Groups > comp.lang.python > #28197

Re: how to get character hex number?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.074
X-Spam-Evidence '*H*': 0.85; '*S*': 0.00; 'encode': 0.09; 'subject:number': 0.09; 'aug': 0.13; 'wrote:': 0.17; '>>>': 0.18; '31,': 0.22; 'header:In-Reply-To:1': 0.25; 'message- id:@mail.gmail.com': 0.27; '>>>>': 0.29; "skip:' 10": 0.30; 'fri,': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'skip:u 20': 0.36; 'skip:p 20': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'skip:6 10': 0.63; 'subject:get': 0.81; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=aPj798lbu9ymun88PE4n8nIxBuYRrS9sTI4ZN033Lcw=; b=ErhndvWHMwvdTNHq43GWj2bCuhQqoTQWc+woL3kEjWhvklKSyMtpusb2K25wHh8jdn 1aGaOUPuyA8bbq/C4MbXxFsOYKeOJEsrMCEWLgD0mO5MHL/fyuQYv/Ev9jpG976Zvu51 1zM6tz4jlkWN8PPF7NxT+SV9Jjr35wG9q3/RB6xggAN9fpUmgyBZwdIM8gEo3CZ95HSn uqQKdotTMUmBKoANyEasFVydTFfJCHSbR995MZSWjNsUfW3ZZ4ywMMKxtJCftrQBL979 k+sYXI1zJVlv7mK3fN1lLRm1W/ligziQWRAhenQZTnOlIKxXAIYWYRpNM9ZIkTIA58I/ VqXA==
MIME-Version 1.0
In-Reply-To <CA+YdQ_66ap1tQCRibdkntGvHqE1sp+Nv_kK2iiKh50GoAa=K6Q@mail.gmail.com>
References <CA+YdQ_66ap1tQCRibdkntGvHqE1sp+Nv_kK2iiKh50GoAa=K6Q@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 31 Aug 2012 20:40:32 -0600
Subject Re: how to get character hex number?
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17.1346467264.27098.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346467264 news.xs4all.nl 6875 [2001:888:2000:d::a6]:45705
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28197

Show key headers only | View raw


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


Thread

Re: how to get character hex number? Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-31 20:40 -0600

csiph-web