首页 新闻 赞助 找找看

xml转换格式

0
悬赏园豆:50 [已解决问题] 解决于 2019-09-26 11:43

json文件格式如何转为pointData: [
{name: 'point-0001', x: 5000, y: 1500},
{name: 'point-0002', x: 5000, y: 10000},
{name: 'point-0004', x: 10000, y: 5000},
{name: 'point-0005', x: 15000, y: 10000},
{name: 'point-0006', x: 15000, y: 5000},
{name: 'point-0007', x: 20000, y: 10000},
{name: 'point-0008', x: 20000, y: 1500},
{name: 'point-0009', x: 5000, y: 15000},
{name: 'point-0010', x: 5000, y: 20000},
{name: 'point-0011', x: 10000, y: 15000},
{name: 'point-0012', x: 15000, y: 15000},
{name: 'point-0013', x: 20000, y: 15000},
{name: 'point-0014', x: 25000, y: 10000},
{name: 'point-0015', x: 25000, y: 15000},
{name: 'point-0016', x: 30000, y: 10000},
{name: 'point-0017', x: 30000, y: 5000},
{name: 'point-0018', x: 30000, y: 15000},
{name: 'point-0019', x: 35000, y: 10000},
{name: 'point-0020', x: 35000, y: 5000},
{name: 'point-0021', x: 35000, y: 15000},
{name: 'point-0022', x: 25000, y: 20000},
{name: 'point-0023', x: 35000, y: 20000},
{name: 'point-0024', x: 45000, y: 25000},
{name: 'point-0025', x: 10000, y: 10000},],

或者是xml文件格式如何转为

pointData: [
{name: 'point-0001', x: 5000, y: 1500},
{name: 'point-0002', x: 5000, y: 10000},
{name: 'point-0004', x: 10000, y: 5000},
{name: 'point-0005', x: 15000, y: 10000},
{name: 'point-0006', x: 15000, y: 5000},
{name: 'point-0007', x: 20000, y: 10000},
{name: 'point-0008', x: 20000, y: 1500},
{name: 'point-0009', x: 5000, y: 15000},
{name: 'point-0010', x: 5000, y: 20000},
{name: 'point-0011', x: 10000, y: 15000},
{name: 'point-0012', x: 15000, y: 15000},
{name: 'point-0013', x: 20000, y: 15000},
{name: 'point-0014', x: 25000, y: 10000},
{name: 'point-0015', x: 25000, y: 15000},
{name: 'point-0016', x: 30000, y: 10000},
{name: 'point-0017', x: 30000, y: 5000},
{name: 'point-0018', x: 30000, y: 15000},
{name: 'point-0019', x: 35000, y: 10000},
{name: 'point-0020', x: 35000, y: 5000},
{name: 'point-0021', x: 35000, y: 15000},
{name: 'point-0022', x: 25000, y: 20000},
{name: 'point-0023', x: 35000, y: 20000},
{name: 'point-0024', x: 45000, y: 25000},
{name: 'point-0025', x: 10000, y: 10000},],

冻死了开发的主页 冻死了开发 | 初学一级 | 园豆:105
提问于:2019-08-22 11:08
< >
分享
最佳答案
0
import json
import codecs
from xmltodict import parse

# json文件
file = codecs.open('test.json', 'r', 'utf-8').read()
data = json.loads(file)
print(data)

# xml 转 dict
file = codecs.open('test.xml', 'r', 'utf-8').read()
data = parse(file)
print(data)
收获园豆:50
Masako | 小虾三级 |园豆:1893 | 2019-08-23 14:41
其他回答(1)
0

->反序列化到对象->序列化到xml

没有其他解,至于第一步对象你可以用通用的,也可以写不通用的,module很多方法也有很多。

花飘水流兮 | 园豆:13560 (专家六级) | 2019-08-22 14:08

大神,我还是没听明白,方便花点时间给下具体的实现吗

支持(0) 反对(0) 冻死了开发 | 园豆:105 (初学一级) | 2019-08-22 14:11

方便加个微信吗大哥

支持(0) 反对(0) 冻死了开发 | 园豆:105 (初学一级) | 2019-08-22 14:13

帮帮忙,急需,以后要是能帮到你的地方,义不容辞

支持(0) 反对(0) 冻死了开发 | 园豆:105 (初学一级) | 2019-08-22 14:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册