Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
octal instead of hex
#1
i can convert binary characters to a literal text form with ascii() (repr() in py2) but it converts most characters to a hexadecimal escape form like '\x00\xff', with simpler control characters like newline converted to '\n'. but i want the octal escape form, like '\000\377'. this form can be used in source code literals. is there a function like ascii() that can give the octal form for bytes in range(256) (ok if it gives control escapes like '\n' for control characters like chr(10) instead of '\012')? i am hoping that i don't need to construct the result myself with a bunch of oct() calls.
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
octal instead of hex - by Skaperen - Jun-05-2017, 03:25 AM
RE: octal instead of hex - by rrashkin - Jun-05-2017, 01:30 PM
RE: octal instead of hex - by Larz60+ - Jun-05-2017, 04:18 PM
RE: octal instead of hex - by wavic - Jun-05-2017, 08:00 PM
RE: octal instead of hex - by Skaperen - Jun-06-2017, 02:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  regex octal replace chaz_sliger 1 2,950 Sep-06-2018, 01:21 AM
Last Post: scidam
  octal encoding Skaperen 4 4,091 Dec-06-2017, 02:53 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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