How to Use str() Function in PythonPython Basics


The str () function converts an object into a human-readable form.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

s = '2019'
print(s)

dict = {'A': '1', 'B': '2'};
print(dict)

Output:

2019
{'A': '1', 'B': '2'}

Syntax

str(object)

Parameters

object — any object

Return Value

It returns a string object.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us