Hướng dẫn int to string python
View Discussion Show Improve Article Save Article View Discussion Improve Article Save Article In Python an integer can be converted into a string using the built-in str() function. The str() function takes in any python data type and converts it into a string. But use of the str() is not the only way to do so. This type of conversion can also be done using the “%s” keyword, the .formatfunction or using f-stringfunction. Below is the list of possible ways to convert an integer to string in python: 1. Using str() function
Example: Python3
Output: Type of variable before convertion : 2. Using “%s” keyword
Example: Python3
Output: Type of variable before convertion : 3. Using .format() function
Example: Python3
Output: Type before convertion : 4. Using f-string
Example: Python3
Output: Type before convertion : 5. Using __str__() method
Python3
Output: Type before convertion : |