Python Forum
convert a character to numeric and back
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert a character to numeric and back
#2
The type info is lost after ord(). Can't get it back unless store it first.

t = type(c)
n = ord(c)
...later
try:
    t(chr(n), encoding='utf8')
except TypeError:
    chr(n)
Reply


Messages In This Thread
RE: convert a character to numeric and back - by jfong - Jan-28-2020, 07:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Numeric Enigma Machine idev 9 563 Mar-29-2024, 06:15 PM
Last Post: idev
  Convert dataframe from str back to datafarme Creepy 1 639 Jul-07-2023, 02:13 PM
Last Post: snippsat
Question Numeric Anagrams - Count Occurances monty024 2 1,516 Nov-13-2021, 05:05 PM
Last Post: monty024
  How to get datetime from numeric format field klllmmm 3 2,009 Nov-06-2021, 03:26 PM
Last Post: snippsat
  [solved] unexpected character after line continuation character paul18fr 4 3,437 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  Extract continuous numeric characters from a string in Python Robotguy 2 2,657 Jan-16-2021, 12:44 AM
Last Post: snippsat
  SyntaxError: unexpected character after line continuation character siteshkumar 2 3,199 Jul-13-2020, 07:05 PM
Last Post: snippsat
  How to calculate column mean and row skip non numeric and na Mekala 5 4,966 May-06-2020, 10:52 AM
Last Post: anbu23
  How do I convert this string back to a list of integers? donmerch 6 3,739 Apr-05-2020, 06:43 PM
Last Post: donmerch
  Alpha numeric element list search rhubarbpieguy 1 1,797 Apr-01-2020, 12:41 PM
Last Post: pyzyx3qwerty

Forum Jump:

User Panel Messages

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