Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hexadecimal world
#3
I was very angry about the leading 0x until I have seen binascii and formatting.

In [22]: import binascii                                                        

In [23]: binascii.hexlify(b'Hello World')                                       
Out[23]: b'48656c6c6f20576f726c64'

In [24]: binascii.unhexlify(_)                                                  
Out[24]: b'Hello World'

In [25]: x = 42                                                                 

In [26]: f'{x:x}'                                                               
Out[26]: '2a'

In [27]: f'{x:010x}'                                                            
Out[27]: '000000002a'
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
hexadecimal world - by Skaperen - Apr-05-2019, 05:39 AM
RE: hexadecimal world - by Larz60+ - Apr-05-2019, 07:37 AM
RE: hexadecimal world - by Skaperen - Apr-07-2019, 02:47 AM
RE: hexadecimal world - by DeaD_EyE - Apr-05-2019, 10:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Hack the world! - soon wavic 3 3,513 Apr-05-2017, 08:22 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020