str()

Python 内置函数 Python 内置函数

描述

str() 函数将对象转化为适于人阅读的形式。

语法

以下是 str() 方法的语法:

class str(object='')

参数

返回值

返回一个对象的string格式。

实例

以下展示了使用 str() 方法的实例:

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

Python 内置函数 Python 内置函数