This post will discuss how to convert an integer to a string in Python.

1. Using String constructor

The standard solution to convert an object to a string is using the str(object) function.

Download  Run Code

 
The str(object) function internally calls the __str__() function of the object, which returns the object’s string representation.

Download  Run Code

2. Using f-strings

Another Pythonic approach is to use the f-string (formatted string literal) starting with Python 3.6. You can do this by prefixing the string literal with f so that the replacement fields within the curly braces {} gets evaluated at the run time.

Download  Run Code

3. Using str.format() function

Before version 3.6, you can use the str.format() function. Here’s an example of its usage:

Download  Run Code

That’s all about converting an integer to a string in Python.