python生成json_如何将Python数组转为Json格式数据并存储?

本文介绍了在Python中如何使用json.dumps()和json.dump()方法将Python数组转换为JSON格式的数据,并进行存储。示例代码展示了具体操作过程。
摘要由CSDN通过智能技术生成

在Python中将数组转为Json数据存储时需要用到将json模块中的json.dumps()或者json.dump()方法。

·json.dumps()方法用法

使用json.dumps( )方法将Python数组转为json格式数据

# 导入json模块

import json

# 定义Python数组

py_list = [{'JavaEE': "http://java.itheima.com"},

{'HTML$JS+前端': "http://web.itheima.com"},

{'大数据': "http://cloud.itheima.com"},

{'Python': "http://python.itheima.com"},

{'人工智能': "http://ai.itheima.com"},

{'软件测试': "http://test.itheima.com"},

{'C++': "http://c.itheima.com"},

{'UI/UE设计': "http://ui.itheima.com"},

{'产品经理': "http://pm.itheima.com"},

{'Linux云计算+运维开发': "http://linux.itheima.com"},

{'新媒体+短视频直播运营': "http://java.itheima.com"},

{'拍摄剪辑': "http://movies.itheima.com"},

{

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值