str()
Built-in FunctionPython 2.0+Beginner
Converts a value to a string
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
print(str(42)) print(str(3.14)) print(str([1, 2, 3])) print(str(True))
str() is a built-in function that converts a value to a string.
Try in PlaygroundTags
builtinfunctioncoredatatypestringconversiontext
Related Items
repr()
Built-in Function
Returns a developer-friendly string representation of an object
format()
Built-in Function
Formats a value according to a format specification string
bytes()
Built-in Function
Creates an immutable sequence of bytes
int()
Built-in Function
Converts a value to an integer
float()
Built-in Function
Converts a value to a floating-point number
__str__
Dunder Method
Returns a human-readable string representation (used by print and str())