目录

str(dict)

描述 (Description)

方法str()生成字典的可打印字符串表示。

语法 (Syntax)

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

str(dict)

参数 (Parameters)

  • dict - 这是字典。

返回值 (Return Value)

此方法返回字符串表示。

例子 (Example)

以下示例显示了str()方法的用法。

#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7};
print "Equivalent String : %s" % str (dict)

当我们运行上面的程序时,它产生以下结果 -

Equivalent String : {'Age': 7, 'Name': 'Zara'}
↑回到顶部↑
WIKI教程 @2018