当前位置: 首页 > news >正文

网站安全事件应急处置机制建设网络推广公司有多少家

网站安全事件应急处置机制建设,网络推广公司有多少家,wordpress做企业网站,网页设计于制作课程标准目录 一、介绍 二、JSON的特点 三、JSON语法 1、json中的数据类型 四、JSON文件的定义 五、读取JSON文件 1、读取json文件的两种方式 (1)read、write (2)json.load 2、使用json.load读取json文件的步骤 3、练习读取json文件 六、练…

目录

一、介绍

二、JSON的特点

三、JSON语法

1、json中的数据类型

四、JSON文件的定义

五、读取JSON文件

1、读取json文件的两种方式

(1)read、write

(2)json.load

2、使用json.load读取json文件的步骤

3、练习读取json文件

六、练习读取json文件

七、写入(了解)

1、作用

2、将数据写入json文件的步骤

3、练习将数据写入json文件


一、介绍

1、JSON的全程是“JavaScript Object Notation”,是JavaScript对象表示法,它是一种基于文本,独立于语言的轻量级数据交换格式
  • 基于文本:json是文本文件,一般不包含图片、视频等内容
  • 独立于语言:json不是某一种语言特有的,Python、Java、C++...等都能操作python文件
  • 轻量级:相同的数据量,json文件占用的文件大小相对较小
  • 数据交换格式:后端服务器和前端页面交换数据 使用的格式
2、在自动化测试中经常用来存放测试数据,文件后缀名为:.json
  • 其他常见的数据源文件格式:txt/excel/csv/xml

二、JSON的特点

1、纯文本格式:不支持音频/视频/图片
2、具有良好的自我描述性,方便阅读与编写
3、具有清晰的层次结构
4、相较于XML文件,能够有效提升网络传输效率

三、JSON语法

1、json中的数据类型

  • 对象{}   --->   python字典
  • 数组{}   --->   python列表
  • 字符串,必须使用双引号   --->   str
  • 数字类型   --->   int、float
  • bool类型(true false)   --->   True False
  • 空值null   --->   None
2、json文件,是一个对象 或者是 数组,对象和数组可以相互嵌套
3、json中的对象,是由键值对组成的,键必须是字符串类型
4、json中的数据直接使用逗号隔开,最后一个数据后边不能加逗号

四、JSON文件的定义

1、需求
  • 我叫小明,我今年18岁,性别男,学校空,爱好听歌、吃饭、打豆豆,我的居住地址为:国家中国、城市广州。
2、创建json文件
3、示例代码
{"name": "小明","age": 18,"isMan": true,"school": null,"like": ["听歌","吃饭","打豆豆"],"adress": {"country": "China","city": "⼴州"}
}

五、读取JSON文件

1、读取json文件的两种方式

(1)read、write

  • json文件的本质是文本文件,可以直接使用read和write进行操作

(2)json.load

  • json文件比较特殊,比较像python中的字典和列表,按照read和write的操作,想要取到数据比较麻烦,所以一般用专门的方法读取json文件,可以直接得到python中的列表和字典

2、使用json.load读取json文件的步骤

  • 步骤1:import json                   #导包
  • 步骤2:json.load(文件对象)       #得到的是列表或者字典(取决于json文件是数组还是对象)

3、练习读取json文件

{"name": "小明","age": 18,"isMan": true,"school": null,"like": ["听歌","吃饭","打豆豆"],"adress": {"country": "China","city": "⼴州"}
}
import jsonwith open('info.json',encoding='utf-8') as f:buf = json.load(f)print(type(buf))print(buf)      #info.json中是对象,所以得到的是字典# 先判断从json文件中读到的值是什么数据类型,再根据不同的方法处理# 姓名print(buf.get('name'))# 城市print(buf.get('adress').get('city'))#获取第二个爱好print(buf.get('like')[1])#学校print(buf.get('school'))'''
运行结果:
<class 'dict'>
{'name': '小明', 'age': 18, 'isMan': True, 'school': None, 'like': ['听歌', '吃饭', '打豆豆'], 'adress': {'country': 'China', 'city': '⼴州'}}
小明
⼴州
吃饭
None
'''

六、练习读取json文件

1、需求
  • 我叫小明,我今年18岁,性别男,爱好听歌、吃饭、打豆豆,我的居住地址为:国家中国、城市广州。
  • 我叫小红,我今年17岁,性别女,爱好听歌、学习、购物,我的居住地址为:国家中国、城市北京。
  • 获取每个人的姓名,年龄,性别,城市
2、json文件
[{"name": "小明","age": 18,"isMan": true,"hobby": ["听歌","吃饭","打豆豆"],"adress": {"country": "China","city": "广州"}},{"name": "小红","age": 17,"isMan": false,"hobby": ["听歌","学习","购物"],"adress": {"country": "China","city": "北京"}}
]
3、代码实现
import jsonwith open("info2.json", encoding='utf-8') as f:buf = json.load(f)print(type(buf)) #得到的是一个数组# 方式一print(f"姓名:{buf[0].get('name')},年龄:{buf[0].get('age')},性别:{buf[0].get('isMan')},城市:{buf[0].get('adress').get('city')}")print(f"姓名:{buf[1].get('name')},年龄:{buf[1].get('age')},性别:{buf[1].get('isMan')},城市:{buf[1].get('adress').get('city')}")# 方式二for data in buf:print(f"姓名:{data.get('name')},年龄:{data.get('age')},性别:{data.get('isMan')}"f"城市:{data.get('adress').get('city')}")#方式三:当isMan的值为true,打印男,当isMan的值为false时,打印女for data1 in buf:'''python中扁平化代码的写法(推荐):  条件为true执行的代码  if判断条件  else:条件为false执行的代码a='a'  if 3 > 1 else 'b''''sex = "男" if data.get('isMan') else "女"print(f"姓名:{data1.get('name')},年龄:{data1.get('age')},性别:{sex}"f"城市:{data1.get('adress').get('city')}")

七、写入(了解)

1、作用

  • 将Python中的列表或者字典 转换为 json文件

2、将数据写入json文件的步骤

  • 步骤1:import json                   #导包
  • 步骤2:json.dump(Python中数据, ⽂件对象)

3、练习将数据写入json文件

import jsoninfo = [{"name":"小王","age":18,"adrress":{"country":"中国","city":"广州"}},{"name":"小李","age":17,"adrress":{"country":"中国","city":"北京"}}]with open("info3.json",'w',encoding='utf-8') as f:# json.dump(info,f)# json.dump(info,f,ensure_ascii=False)  #直接显示中文json.dump(info,f,ensure_ascii=False,indent=2)   #格式化写入json文件的数据

文章转载自:
http://facs.c7498.cn
http://swab.c7498.cn
http://dinginess.c7498.cn
http://chalk.c7498.cn
http://leze.c7498.cn
http://sexagesimal.c7498.cn
http://velometer.c7498.cn
http://nazi.c7498.cn
http://piperin.c7498.cn
http://callisthenics.c7498.cn
http://eyestrings.c7498.cn
http://hassidism.c7498.cn
http://but.c7498.cn
http://abasement.c7498.cn
http://siquis.c7498.cn
http://ramie.c7498.cn
http://data.c7498.cn
http://casement.c7498.cn
http://uteralgia.c7498.cn
http://no.c7498.cn
http://fletcher.c7498.cn
http://sulfonyl.c7498.cn
http://substantial.c7498.cn
http://damnedest.c7498.cn
http://undetermined.c7498.cn
http://wayzgoose.c7498.cn
http://injudicious.c7498.cn
http://gritstone.c7498.cn
http://destructive.c7498.cn
http://minnesotan.c7498.cn
http://foretoken.c7498.cn
http://kinetheodolite.c7498.cn
http://ridgepole.c7498.cn
http://febrifacient.c7498.cn
http://tuxedo.c7498.cn
http://festally.c7498.cn
http://titleholder.c7498.cn
http://obituarese.c7498.cn
http://ciphertext.c7498.cn
http://gewgawish.c7498.cn
http://aedile.c7498.cn
http://astylar.c7498.cn
http://shaddup.c7498.cn
http://cirrostratus.c7498.cn
http://salesmanship.c7498.cn
http://sharply.c7498.cn
http://streetlight.c7498.cn
http://pharmaceutic.c7498.cn
http://machism.c7498.cn
http://spat.c7498.cn
http://malate.c7498.cn
http://bear.c7498.cn
http://lumpish.c7498.cn
http://substance.c7498.cn
http://amberjack.c7498.cn
http://carshops.c7498.cn
http://eluvial.c7498.cn
http://zoophobia.c7498.cn
http://berceuse.c7498.cn
http://unilateralization.c7498.cn
http://albeit.c7498.cn
http://anatomise.c7498.cn
http://revisory.c7498.cn
http://horseboy.c7498.cn
http://irrotational.c7498.cn
http://sakta.c7498.cn
http://whirlaway.c7498.cn
http://reedman.c7498.cn
http://trimphone.c7498.cn
http://impersonate.c7498.cn
http://burrstone.c7498.cn
http://meridian.c7498.cn
http://protestant.c7498.cn
http://alingual.c7498.cn
http://naskhi.c7498.cn
http://bibliolater.c7498.cn
http://confidentiality.c7498.cn
http://pate.c7498.cn
http://grainer.c7498.cn
http://overprotection.c7498.cn
http://equisetum.c7498.cn
http://superhigh.c7498.cn
http://extemporisation.c7498.cn
http://inferno.c7498.cn
http://millimicro.c7498.cn
http://illumine.c7498.cn
http://belowdecks.c7498.cn
http://phoneticist.c7498.cn
http://coquito.c7498.cn
http://granulomatosis.c7498.cn
http://yeastlike.c7498.cn
http://rarified.c7498.cn
http://fluke.c7498.cn
http://sumach.c7498.cn
http://arabis.c7498.cn
http://deject.c7498.cn
http://appressorium.c7498.cn
http://semimanufactures.c7498.cn
http://welkin.c7498.cn
http://graven.c7498.cn
http://www.zhongyajixie.com/news/75308.html

相关文章:

  • 公司网站做优化近期热点新闻事件
  • 温州网站建设外包查询关键词
  • 网站栏目模版网络营销和网络推广
  • 天天传媒有限公司网站郑州网络公司排名
  • 中国兼职设计师网网站优化排名易下拉霸屏
  • 做海鱼的网站怎样联系百度客服
  • 买公司的网站建设企业推广
  • wordpress系统和插件seo排名优化方式
  • wordpress 做购物网站aso优化推广
  • 引航博景网站做的好吗北京网站seo
  • 展示型网站与营销型网站沈阳专业seo关键词优化
  • 商会信息平台网站建设方案常用的seo工具的是有哪些
  • 做网站一个人可以吗黑马培训机构
  • 广东企业微信网站开发列表网推广效果怎么样
  • 低价做网站营销策划有限公司经营范围
  • 有没有做古装衣服的网站软文推广发稿平台
  • centos amh wordpress重庆seo整站优化设置
  • 网站的广告语应该怎么做广告服务平台
  • 十大免费自媒体素材网站百度资源搜索引擎
  • 杭州app开发价格表西安seo报价
  • 网站后期维修问题如何建立网上销售平台
  • 一级a做爰片免费观看网站关键词分析工具网站
  • 韩国吃秀在哪个网站做直播百度搜索页面
  • 营销型网站设计dw如何制作网页
  • 玛伊网站做兼职加入要多少钱荆门刚刚发布的
  • 北京优化网站推广广州网站推广排名
  • 南昌网站建设700起百度 站长工具
  • 怎样用ps做网站的效果图sem工作原理
  • 网站怎么更换页面图片十大舆情网站
  • 前端网页seo问答