Python 字典(Dictionary) str()方法

栏目: 编程语言 · Python · 编程教程 · python 教程 · 发布时间: 9年前

内容简介:Python 字典(Dictionary) str() 函数将值转化为适于人阅读的形式,以可打印的字符串表示。

描述

Python 字典(Dictionary) str() 函数将值转化为适于人阅读的形式,以可打印的字符串表示。

语法

str()方法语法:

str(dict)

参数

  • dict -- 字典。

返回值

返回字符串。

实例

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

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7};
print "Equivalent String : %s" % str (dict)

以上实例输出结果为:

Equivalent String : {'Age': 7, 'Name': 'Zara'}

以上所述就是小编给大家介绍的《Python 字典(Dictionary) str()方法》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Flexible Rails

Flexible Rails

Peter Armstrong / Manning Publications / 2008-01-23 / USD 44.99

Rails is a fantastic tool for web application development, but its Ajax-driven interfaces stop short of the richness you gain with a tool like Adobe Flex. Simply put, Flex is the most productive way t......一起来看看 《Flexible Rails》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码