Python Forum
difficult string conversion need help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
difficult string conversion need help
#4
Thanks, that was easy.

According to the documentation, one can use bytes.fromhex() instead of a2b_hex(). It's a little prettier
import struct

s = '2692692A7BAE0E47430678A4B4382D13F032AE1C509ED523EF747FF795260E917A0DA53F07140C408DA814235B0A2BDD3EBA832D8F2C82FE0AD1B0FD092515A475C04BC130D77E3C'

for x in (s[k:k+16] for k in range(0, len(s), 3*16)):
    i = struct.unpack('<Q', bytes.fromhex(x))[0]
    print(x, i)
Pir8Radio likes this post
Reply


Messages In This Thread
RE: difficult string conversion need help - by Gribouillis - Nov-27-2022, 06:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  creating simplex tableau pivot program easy or difficult for a beginner in Python? alex_0 2 2,677 Mar-31-2021, 03:39 AM
Last Post: Larz60+
  How to solve difficult non-linear equations? shreeniket 3 2,464 Apr-23-2020, 01:36 AM
Last Post: shreeniket
  Programming Difficult math in Python Huntern 6 4,936 Oct-17-2019, 06:32 AM
Last Post: Huntern
  Very difficult challenge for me cristfp 1 2,805 Apr-01-2019, 08:45 PM
Last Post: Yoriz
  Why is basic Twitter Connectivity So Difficult? Not sure what I'm doing wrong. Oliver 0 1,959 Mar-10-2018, 12:38 PM
Last Post: Oliver
  Python installation difficult rajamugavai 2 2,992 Feb-27-2018, 02:18 PM
Last Post: sparkz_alot
  string conversion like in source code Skaperen 4 3,996 Nov-26-2017, 03:29 AM
Last Post: Skaperen
  Projected Surface in 2D [Difficult topic] Hans_K 6 4,003 Aug-02-2017, 09:16 AM
Last Post: Hans_K

Forum Jump:

User Panel Messages

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