Python 字典(Dictionary) str()方法
Python 字典(Dictionary) str()方法
描述
Python 字典(Dictionary) str() 函数将值转化为适于人阅读的形式,以可打印的字符串表示。高佣联盟 www.cgewang.com
语法
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()方法的更多相关文章
- Python 字典(Dictionary) clear()方法
Python 字典(Dictionary) clear()方法 描述 Python 字典(Dictionary) clear() 函数用于删除字典内所有元素.高佣联盟 www.cgewang.com ...
- Python 字典(Dictionary) type()方法
Python 字典(Dictionary) type()方法 描述 Python 字典(Dictionary) type() 函数返回输入的变量类型,如果变量是字典就返回字典类型.高佣联盟 www.c ...
- Python 字典(Dictionary) len()方法
Python 字典(Dictionary) len()方法 描述 Python 字典(Dictionary) len() 函数计算字典元素个数,即键的总数.高佣联盟 www.cgewang.com 语 ...
- Python 字典(Dictionary) cmp()方法
Python 字典(Dictionary) cmp()方法 描述 Python 字典的 cmp() 函数用于比较两个字典元素.高佣联盟 www.cgewang.com 语法 cmp()方法语法: cm ...
- Python 字典(Dictionary) copy()方法
描述 Python 字典(Dictionary) copy() 函数返回一个字典的浅复制.高佣联盟 www.cgewang.com 语法 copy()方法语法: dict.copy() 参数 NA. ...
- Python 字典(Dictionary) get()方法
描述 Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值. 语法 get()方法语法: dict.get(key, default=None) 参数 ...
- Python 字典(Dictionary) setdefault()方法
描述 Python 字典(Dictionary) setdefault() 函数和get()方法类似, 如果键不已经存在于字典中,将会添加键并将值设为默认值. 语法 setdefault()方法语法: ...
- Python 字典(Dictionary) has_key()方法
描述 Python 字典(Dictionary) has_key() 函数用于判断键是否存在于字典中,如果键在字典dict里返回true,否则返回false. 语法 has_key()方法语法:dic ...
- Python 字典(Dictionary) values()方法
描述 Python 字典(Dictionary) values() 函数以列表返回字典中的所有值. 语法 values()方法语法: dict.values() 参数 NA. 返回值 返回字典中的所有 ...
随机推荐
- Oracle Online Patching报错"This is not a RAC setup. OPatch cannot determine the local node name"
Oracle Online Patching报错"This is not a RAC setup. OPatch cannot determine the local node name&q ...
- Python3笔记009 - 2.6 输入和输出
第2章 python语言基础 python语法特点 保留字与标识符 变量 数据类型 运算符 输入和输出 2.6 输入和输出 1.input()函数 name = input("请输入姓名:& ...
- css3常见好看的投影效果_css3阴影box-shadow高大上用法
在设计图会经常使用到的阴影效果,如何用css3来实现呢?这篇文章主要整理box-shadow的一些好看常用的投影效果. 1.曲面/椭圆投影效果: 代码如下: <style> .shadow ...
- grunt之easy demo
首先安装grunt-cli cnpm install -g grunt-cli 接下来创建package.json,内容如下 { "name": "demo ...
- 通过手写服务器的方式,立体学习Http
前言 Http我们都已经耳熟能详了,而关于Http学习的文章网上有很多,各个知识点的讲解也可说是深入浅出.然而,学习过后,我们对Http还是一知半解.问题出在了哪? Http是一个客户机与服务器之间的 ...
- Django---进阶16<XSS攻击>
目录 后台管理 添加文章 kindeditor富文本编辑器 编辑器上传图片 修改用户头像 bbs项目总结 后台管理 """ 当一个文件夹下文件比较多的时候 你还可以继续创 ...
- WPF 精准大小的消息气泡生成
在其他网站发布过,都是这里写的. 全部为Wpf方式,生成的气泡宽度高度较为精确. 适用任意字体以及字号,可设置图像字体.字号.行间距.字间距.阴影.气泡宽度等,在RichtextboxHelper.c ...
- scrapy (三) : 请求传参
scrapy 请求传参 1.定义数据结构item.py文件 ''' field: item.py ''' # -*- coding: utf-8 -*- # Define here the model ...
- Django框架09 /ajax、crsf、settings导入
Django框架09 /ajax.crsf.settings导入 目录 Django框架09 /ajax.crsf.settings导入 1. ajax概述 2. ajax应用 3. ajax上传文件 ...
- android 调试的一些问题解决1
1.系统自带的机器跑起来太卡,我想用雷电模拟器来运行.可是打开后找不到设备怎么弄? 解决办法: 步骤1:>>>运行模拟器 步骤2:>>>win + r 打开cmd ...