Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46273
| Date | 2013-05-28 06:59 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Problems with python and pyQT |
| References | <8d8fd7fc-2509-457e-a4c9-0a1ac1f65c02@googlegroups.com> <mailman.2249.1369660253.3114.python-list@python.org> <646e6bae-b0fc-46fe-bf60-23ec9b4958a3@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2291.1369738782.3114.python-list@python.org> (permalink) |
On 05/28/2013 05:41 AM, silusilusilu@gmail.com wrote:
> Thanks for your reply: very useful!!
> I have another question: with hex command i display (for example)
>
> 0x1
>
> is it possible to display 0x01?
hex() is a function, not a command. And it only takes the one
parameter, the int to be converted.
For more generality, try the str.format() method. The x type converts
to hex without any prefix, and then you can add the width and fill field.
http://docs.python.org/2/library/stdtypes.html#str.format
http://docs.python.org/2/library/string.html#formatstrings
http://docs.python.org/2/library/string.html#format-specification-mini-language
For starters, try:
print "0x{0:0>2x}".format(12)
or
print "0x{0:0>2X}".format(12)
if you like uppercase hex characters
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Problems with python and pyQT silusilusilu@gmail.com - 2013-05-27 02:26 -0700
Re: Problems with python and pyQT Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-05-27 15:10 +0200
Re: Problems with python and pyQT silusilusilu@gmail.com - 2013-05-28 02:41 -0700
Re: Problems with python and pyQT Dave Angel <davea@davea.name> - 2013-05-28 06:59 -0400
csiph-web