You are looking for the chr function.

You seem to be mixing decimal representations of integers and hex representations of integers, so it's not entirely clear what you need. Based on the description you gave, I think one of these snippets shows what you want.

>>> chr(0x65) == '\x65'
True


>>> hex(65)
'0x41'
>>> chr(65) == '\x41'
True

Note that this is quite different from a string containing an integer as hex. If that is what you want, use the hex builtin.

Answer from Mike Graham on Stack Overflow
🌐
W3Schools
w3schools.com › python › ref_func_hex.asp
Python hex() Function
Python Examples Python Compiler ... Plan Python Interview Q&A Python Training ... The hex() function converts the specified number into a hexadecimal value....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-hex-function
hex() function in Python - GeeksforGeeks
July 11, 2025 - hex() function in Python is used to convert an integer to its hexadecimal equivalent. It takes an integer as input and returns a string representing the number in hexadecimal format, starting with "0x" to indicate that it's in base-16.
🌐
Real Python
realpython.com › ref › builtin-functions › hex
hex() | Python’s Built-in Functions – Real Python
The built-in hex() function converts a given integer into its lowercase hexadecimal representation.
🌐
w3resource
w3resource.com › python › built-in-function › hex.php
Python hex() function - w3resource
April 18, 2026 - Python hex() function: The hex() function converts an integer number to a lowercase hexadecimal string prefixed with 0x.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-hex
Python hex() | DigitalOcean
August 3, 2022 - Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
Vultr Docs
docs.vultr.com › python › built-in › hex()
Python hex() - Convert Integer to Hexadecimal
November 25, 2024 - The hex() function in Python is a built-in method used to convert an integer into its corresponding hexadecimal string. This function is particularly useful in fields like cryptography, computer science education, or any scenario where hexadecimal ...
🌐
Programiz
programiz.com › python-programming › methods › built-in › hex
Python hex()
The hex() function converts an integer number to the corresponding hexadecimal string.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › python › python-hex-function.htm
Python hex() Function
When you use the hex() function in Python, it converts a decimal number into its hexadecimal representation, and the result is a string that starts with "0x" followed by the hexadecimal digits.
🌐
Hex Technologies
learn.hex.tech › analyze & build › python cells
Python cells | Learn | Hex Technologies
Users can edit and execute any valid Python in a Python cell. Hex projects come pre-installed with a number of Python packages, which you can view in the Environment tab of the left sidebar.
🌐
Tutorial Teacher
tutorialsteacher.com › python › python-hex
Python hex
The hex() function converts a decimal integer into hexadecimal number with 0x prefix.
🌐
AskPython
askpython.com › python › built-in-methods › python-hex-function
How to use the Python hex() function? - AskPython
August 6, 2022 - This function is useful if you want to convert an Integer to a hexadecimal string, prefixed with “0x”. Let’s look at how we could use this function. The Python hex() function has a very simple syntax:
🌐
Scaler
scaler.com › home › topics › python hex
python hex() Function - Scaler Topics
May 4, 2023 - The hex() function in Python3 is a built-in function that converts a specified integer number into its corresponding hexadecimal form.
🌐
DEV Community
dev.to › days_64 › python-hex-function-convert-decimal-to-hexadecimal-33am
Python hex() function, convert decimal to hexadecimal - DEV Community
March 2, 2020 - The Python hex() function is used to convert decimal to hexadecimal integers, as a string. You may...
🌐
TutorialKart
tutorialkart.com › python › python-hex
Python hex() Builtin Function - Examples
April 3, 2023 - Python hex() builtin function takes an integer and returns its hexadecimal representation in string type. In this tutorial, we will learn about the syntax of Python hex() function, and learn how to use this function with the help of examples.
🌐
Centron
centron.de › startseite › python hex() function
Python hex() Function
February 6, 2025 - Python hex() function is used to convert an integer to a lowercase hexadecimal string prefixed with “0x”. We can also pass an object to hex() function, in that case the object must have __index__() function defined that returns integer.
🌐
LabEx
labex.io › tutorials › python-how-to-format-the-hexadecimal-output-in-python-417964
How to format the hexadecimal output in Python | LabEx
Different ways to format hexadecimal output in Python: -------------------------------------------------- 1. Using the format() function: Basic format: ab Uppercase: AB With 0x prefix: 0xab With 0X prefix and uppercase: 0XAB Padded to 4 digits: 00ab Padded with spaces: ab 2.
🌐
LabEx
labex.io › home › builtin › hex
Python hex() built-in function - Python Cheat Sheet
The hex() function in Python is a built-in function that converts an integer into its corresponding hexadecimal representation. The resulting string is prefixed with “0x” to indicate that it is a hexadecimal value.