Here's how to directly print to a console, although a library like curses is definitely easier.

Figure out what characters your console supports:

import sys
print('encoding =',sys.stdout.encoding)
print(bytes(range(256)).decode(sys.stdout.encoding)
encoding = cp437
 โ˜บโ˜ปโ™ฅโ™ฆ
โ™ซโ˜ผโ–บโ—„โ†•โ€ผยถยงโ–ฌโ†จโ†‘โ†“โ†’โ†โˆŸโ†”โ–ฒโ–ผ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~โŒ‚ร‡รผรฉรขรคร 
รฅรงรชรซรจรฏรฎรฌร„ร…ร‰รฆร†รดรถรฒรปรนรฟร–รœยขยฃยฅโ‚งฦ’รกรญรณรบรฑร‘ยชยบยฟโŒยฌยฝยผยกยซยปโ–‘โ–’โ–“โ”‚โ”คโ•กโ•ขโ•–โ••โ•ฃโ•‘โ•—โ•โ•œโ•›โ”โ””โ”ดโ”ฌโ”œโ”€โ”ผโ•žโ•Ÿโ•šโ•”โ•ฉโ•ฆโ• โ•โ•ฌโ•งโ•จโ•คโ•ฅโ•™โ•˜โ•’โ•“โ•ซโ•ชโ”˜โ”Œโ–ˆโ–„โ–Œโ–โ–€ฮฑรŸฮ“ฯ€ฮฃฯƒยตฯ„ฮฆฮ˜ฮฉฮดโˆžฯ†ฮตโˆฉโ‰กยฑโ‰ฅโ‰คโŒ โŒกรทโ‰ˆยฐโˆ™ยทโˆšโฟยฒ
โ– 

Then print them as Unicode characters. Make sure to save the source file in UTF-8 (Python 3's default) or declare the encoding used in the source file with a #coding: encoding comment. UTF-8 can handle any character, but if you print one your terminal doesn't support you'll get a UnicodeEncodeError in pre-3.6 Python.

print('โ•”โ•โ•ฆโ•โ•—โ•“โ”€โ•ฅโ”€โ•–โ•’โ•โ•คโ•โ••โ”Œโ”€โ”ฌโ”€โ”')
print('โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚')
print('โ• โ•โ•ฌโ•โ•ฃโ•Ÿโ”€โ•ซโ”€โ•ขโ•žโ•โ•ชโ•โ•กโ”œโ”€โ”ผโ”€โ”ค')
print('โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚')
print('โ•šโ•โ•ฉโ•โ•โ•™โ”€โ•จโ”€โ•œโ•˜โ•โ•งโ•โ•›โ””โ”€โ”ดโ”€โ”˜')
โ•”โ•โ•ฆโ•โ•—โ•“โ”€โ•ฅโ”€โ•–โ•’โ•โ•คโ•โ••โ”Œโ”€โ”ฌโ”€โ”
โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚
โ• โ•โ•ฌโ•โ•ฃโ•Ÿโ”€โ•ซโ”€โ•ขโ•žโ•โ•ชโ•โ•กโ”œโ”€โ”ผโ”€โ”ค
โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚
โ•šโ•โ•ฉโ•โ•โ•™โ”€โ•จโ”€โ•œโ•˜โ•โ•งโ•โ•›โ””โ”€โ”ดโ”€โ”˜
Answer from Mark Tolonen on Stack Overflow
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ string โ€บ print-non-ascii-characters-python
How To Print Non-ASCII Characters In Python? - AskPython
July 26, 2023 - Most of the time, for ASCII characters, we use UTF-8, i.e., single-byte representation but non-ASCII character mainly contains multiple bytes. Some examples are โ€˜รฉโ€™ this character is represented as โ€˜U+00E9โ€™ in Unicode. In simple words, we can say that ASCII characters are a small subset of Non-ASCII characters. The ASCII characters are represented in a 7-bit format, and non-ASCII characters are of a broader range. Non-ASCII characters are widely used in Python language to print different symbols and characters from different languages which are not included in the ASCII characters.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-bytes-to-string-how-to-convert-a-bytestring
Python Bytes to String โ€“ How to Convert a Bytestring
April 10, 2023 - If the byte string is not valid ASCII or UTF-8, we will need to specify the encoding format using the encoding parameter. ... # Define a byte string byte_string = b"Hello, world!"
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ bytes but print a string!
r/learnpython on Reddit: bytes but print a string!
January 15, 2022 -

Im learning crypto ctf with python and there is something that really can't figure out on my own

i have a flag encrypted with XOR with a key. they are represented as hex. after convert it to bytes, i xor them and then use it Crypto.Util.number.long_to_bytes() to find the flag.

before the XOR operation, the bytes values is like "\xa6\xc8\xb6s<\x9b"\xde{\xc0%2f\xa3\x86}\xf5Z\xcd\xe8c^\x19\xc73\x13"

after i removed the key that was XOR with the flag, the bytes values of flag is

crypto{x0r_i5_ass0c1at1v3}

i checked the var with type() and it's a bytes not a str. How come that before that its bytes values has hex values and then only normale characters? Or maybe those arent hex?

๐ŸŒ
w3resource
w3resource.com โ€บ python โ€บ python-bytes.php
Python Bytes, Bytearray
>>> # bytes objects are immutable sequences of integers, each value in the sequence >>> # string objects are immutable sequences of unicode characters. >>> x = "Python String" >>> y = b"Python String" >>> print(x) Python String >>> print(y) b'Python String' >>> # Found in unicode representation of characters but not in ascii >>> x = "Python" >>> y = bytes("Python", "utf8") >>> print(x) Python >>> print(y) b'Python' >>>
Top answer
1 of 2
3

Here's how to directly print to a console, although a library like curses is definitely easier.

Figure out what characters your console supports:

import sys
print('encoding =',sys.stdout.encoding)
print(bytes(range(256)).decode(sys.stdout.encoding)
encoding = cp437
 โ˜บโ˜ปโ™ฅโ™ฆ
โ™ซโ˜ผโ–บโ—„โ†•โ€ผยถยงโ–ฌโ†จโ†‘โ†“โ†’โ†โˆŸโ†”โ–ฒโ–ผ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~โŒ‚ร‡รผรฉรขรคร 
รฅรงรชรซรจรฏรฎรฌร„ร…ร‰รฆร†รดรถรฒรปรนรฟร–รœยขยฃยฅโ‚งฦ’รกรญรณรบรฑร‘ยชยบยฟโŒยฌยฝยผยกยซยปโ–‘โ–’โ–“โ”‚โ”คโ•กโ•ขโ•–โ••โ•ฃโ•‘โ•—โ•โ•œโ•›โ”โ””โ”ดโ”ฌโ”œโ”€โ”ผโ•žโ•Ÿโ•šโ•”โ•ฉโ•ฆโ• โ•โ•ฌโ•งโ•จโ•คโ•ฅโ•™โ•˜โ•’โ•“โ•ซโ•ชโ”˜โ”Œโ–ˆโ–„โ–Œโ–โ–€ฮฑรŸฮ“ฯ€ฮฃฯƒยตฯ„ฮฆฮ˜ฮฉฮดโˆžฯ†ฮตโˆฉโ‰กยฑโ‰ฅโ‰คโŒ โŒกรทโ‰ˆยฐโˆ™ยทโˆšโฟยฒ
โ– 

Then print them as Unicode characters. Make sure to save the source file in UTF-8 (Python 3's default) or declare the encoding used in the source file with a #coding: encoding comment. UTF-8 can handle any character, but if you print one your terminal doesn't support you'll get a UnicodeEncodeError in pre-3.6 Python.

print('โ•”โ•โ•ฆโ•โ•—โ•“โ”€โ•ฅโ”€โ•–โ•’โ•โ•คโ•โ••โ”Œโ”€โ”ฌโ”€โ”')
print('โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚')
print('โ• โ•โ•ฌโ•โ•ฃโ•Ÿโ”€โ•ซโ”€โ•ขโ•žโ•โ•ชโ•โ•กโ”œโ”€โ”ผโ”€โ”ค')
print('โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚')
print('โ•šโ•โ•ฉโ•โ•โ•™โ”€โ•จโ”€โ•œโ•˜โ•โ•งโ•โ•›โ””โ”€โ”ดโ”€โ”˜')
โ•”โ•โ•ฆโ•โ•—โ•“โ”€โ•ฅโ”€โ•–โ•’โ•โ•คโ•โ••โ”Œโ”€โ”ฌโ”€โ”
โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚
โ• โ•โ•ฌโ•โ•ฃโ•Ÿโ”€โ•ซโ”€โ•ขโ•žโ•โ•ชโ•โ•กโ”œโ”€โ”ผโ”€โ”ค
โ•‘ โ•‘ โ•‘โ•‘ โ•‘ โ•‘โ”‚ โ”‚ โ”‚โ”‚ โ”‚ โ”‚
โ•šโ•โ•ฉโ•โ•โ•™โ”€โ•จโ”€โ•œโ•˜โ•โ•งโ•โ•›โ””โ”€โ”ดโ”€โ”˜
2 of 2
3

You can use Python curses library, it's a part of standard library on *nix systems, or you can use Urwid that is a higher level library for creating console interfaces.

Constants paragraph of the documentation contains information about how special characters can be drawn in X Emulators (if they support VT100s inherited features). If the emulator doesn't support such alternative character set - ascii approximation is used. I suppose that this is what you're looking for.

๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ python โ€บ print bytes without b in python
Print Bytes without b in Python - Java2Blog
September 21, 2022 - The repr() function is similar to the str() constructor in Python. We can use it to get a string representation of different objects. For a byte object, the repr() function invokes the internal bytes.__repr__ magic method. It returns the bytes object as a string and we can manually slice off the prefix b from the same. See the code below. ... This tutorial demonstrated several methods to print bytes without b in Python.
Find elsewhere
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Display bytes without translation - Python Help - Discussions on Python.org
March 16, 2025 - I am not sure if I am not missing something obvious, but say I have: b = bytes((65, 20)) print(b) # b'A\x14' However, I donโ€™t want to see โ€œAโ€, I want to see hex representation Then yes, I can do: print(b.hex()) โ€ฆ
๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ python โ€บ print bytes as hex in python
Print bytes as hex in Python - Java2Blog
September 26, 2022 - Python 3.5 introduced the hex() function is used to return the Hexadecimal representation of a number. We can use it to directly print Bytes as Hex in Python. First, we will create a Bytes array using the bytes() function and then we will print it as Hexadecimal digits.
๐ŸŒ
Learning Python
learning-python.com โ€บ strings30.html
Python 3.X Strings Tutorial by Mark Lutz
This makes these encodings' data fast to process but may consume extra space and bandwidth, which renders them subpar in many applications. In the following, ASCII bytes print as characters, non-ASCIIs print as \xNN escapes, and each result has a 2- or 4-byte BOM header at the front whose details we're largely skipping here (see the earlier update):
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ convert-bytes-to-string-in-python
Convert Bytes to String in Python
November 27, 2020 - The \xf0\x9f\x8d\x95 represents bytes as two-digit hex numbers as Python doesn't know how to represent them as ASCII characters: >>> u = u"Let's grab a ๐Ÿ•!" u"Let's grab a \U0001f355!"" >>> u "Let's grab a ๐Ÿ•!" # Yum. >>> len(u) 15 ยท As you can see above, the Unicode string contains \U0001f355 - a Unicode escaped character which our terminal now knows how to print out as a slice of pizza!
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ binascii.html
binascii โ€” Convert between binary and ASCII
Changed in version 3.3: ASCII-only unicode strings are now accepted by the a2b_* functions. The binascii module defines the following functions: ... Convert a single line of uuencoded data back to binary and return the binary data. Lines normally contain 45 (binary) bytes, except for the last line.
๐ŸŒ
Google Groups
groups.google.com โ€บ g โ€บ comp.lang.python โ€บ c โ€บ 3nPnNzgBoxQ
"convert" string to bytes without changing data (encoding)
March 28, 2012 - You don't need to pretend like Chris Angelico that there's isn't a direct mapping from the his Python 3 implementation's internal respresentation of strings to bytes in order to label what he's asking for as being "silly". ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... > You can read as bytes and decode as ASCII but ignoring the troublesome > non-text characters: > > >>> print(open('text.txt', 'br').read().decode('ascii', 'ignore')) > Das fr ASCII nicht benutzte Bit kann auch fr Fehlerkorrekturzwecke > (Parittsbit) auf den Kommunikationsleitungen oder fr andere > Steuerungsaufgaben verwendet werden.
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Unusal behavior of python3* print hex values - Python Help - Discussions on Python.org
May 2, 2022 - Iโ€™m new to python but have expierences on other languages. I discoverd an unusal behavior of python3* on my kali linux. All I want was to print an output of 4 values given in hex: This is OK and works how it should be: Python 2.7.18 (default, Mar 28 2022, 20:47:09) [GCC 11.2.0] on linux2 $ python2.7 -c โ€˜print ("\x37\x8a\x04\x08");โ€™ | hexdump -C 00000000 37 8a 04 08 0a |7โ€ฆ| This is my problem: Python 3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0] on l...
๐ŸŒ
Blogger
discountedgerberprotectplus.blogspot.com โ€บ home โ€บ character encoding โ€บ python 3.4
Printing Non-ascii Characters In Python 3 - Python stackoverflow Examples
December 2, 2023 - This also explains why it only errors out when you try to print it to cmd, but you can still use it in boolean comparisons. Not sure what exactly they did in python 2.X to get it functional.