Python str() Function

Python 内置函数Python Built-in Functions


Description

The str() function converts an object into a form readable by humans.

Syntax

The following is the syntax of the str() method:

class str(object='')

Parameters

  • object -- An object.

Return Value

Returns an object in string format.


Examples

The following shows an example of using the str() method:

>>>s = 'EXAMPLE' >>> str(s) 'EXAMPLE' >>> dict = {'example': 'example.com', 'google': 'google.com'}; >>> str(dict) "{'google': 'google.com', 'example': 'example.com'}" >>>

Python 内置函数Python Built-in Functions

Other Extensions