Python Forum
convert hex encoded string to ASCII
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert hex encoded string to ASCII
#1
given a string of hexadecimal characters that represent ASCII characters, i want to convert it to those ASCII characters.  for example:

'707974686f6e2d666f72756d2e696f' -> 'python-forum.io'

in python 2 i can do .decode('hex') but this is gone in python3. so, i found this:
codecs.decode(codecs.decode('707974686f6e2d666f72756d2e696f','hex'),'ascii')
anything simpler that works in either python 2 or python 3 ?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
convert hex encoded string to ASCII - by Skaperen - Sep-29-2016, 07:11 AM
RE: convert hex encoded string to ASCII - by Vexis - Oct-02-2016, 03:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  convert result to hex ascii Jusufs 6 1,554 May-19-2023, 03:21 PM
Last Post: deanhystad
  convert string to float in list jacklee26 6 1,914 Feb-13-2023, 01:14 AM
Last Post: jacklee26
  how to convert tuple value into string mg24 2 2,351 Oct-06-2022, 08:13 AM
Last Post: DeaD_EyE
  Convert string to float problem vasik006 8 3,412 Jun-03-2022, 06:41 PM
Last Post: deanhystad
  Convert a string to a function mikepy 8 2,539 May-13-2022, 07:28 PM
Last Post: mikepy
Question Can you put encoded strings into .txt files? Alivegamer 0 1,264 May-04-2022, 12:50 AM
Last Post: Alivegamer
Question How to convert string to variable? chatguy 5 2,421 Apr-12-2022, 08:31 PM
Last Post: buran
  Convert string to int Frankduc 8 2,483 Feb-13-2022, 04:50 PM
Last Post: menator01
  Convert string to path using Python 2.7 tester_V 10 6,455 Nov-20-2021, 02:20 PM
Last Post: snippsat
  Convert each element of a list to a string for processing tester_V 6 5,336 Jun-16-2021, 02:11 AM
Last Post: tester_V

Forum Jump:

User Panel Messages

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