Python 字典(Dictionary) str()方法

Python 教程 · 2019-02-03 10:14:30

描述

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 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

The Photoshop Anthology

The Photoshop Anthology

Corrie Haffly / SitePoint Pty. Ltd. / 2006 / USD 39.95

The Photoshop Anthology is full-color, question-and-answer book for Web Designers who want to use Photoshop to build Websites and create better looking web graphics more effectively. The book covers: ......一起来看看 《The Photoshop Anthology》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

随机密码生成器
随机密码生成器

多种字符组合密码