Lalalalal666 2021-08-25 19:03 采纳率: 100%
浏览 337
已结题

有偿写一个Python脚本,修改Json数据部分Key名称,并对修改后的数据节选保存新json

本人基础薄弱,时间紧迫,希望各位帮忙一下

现有json数据,需要对其中部分key名称改名,并且对改名后的部分节选出来进行另存为新的json数据。

这里有我找到的可能对应的方法,
python - Change the name of a key in dictionary - Stack Overflow I want to change the key of an entry in a Python dictionary. Is there a straightforward way to do this? https://stackoverflow.com/questions/4406501/change-the-name-of-a-key-in-dictionary

Python将json文件里的key值批量替换_QFIUNE的博客-CSDN博客 #!/usr/bin/env python# -*- coding: utf-8 -*-# @Time : 2020/11/29 10:47# @Author : Qiufen.Chen# @Email : 1760812842@qq.com# @File : replace_id.py# @Software: PyCharmimport osimport jsonindir = '/home/cqfnenu/PsyDrugKB/datasets/keggdrug/. https://blog.csdn.net/weixin_42038527/article/details/110403806?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162983799516780274192348%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=162983799516780274192348&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-2-110403806.first_rank_v2_pc_rank_v29&utm_term=python%E6%89%B9%E9%87%8F%E4%BF%AE%E6%94%B9json%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84Key%E5%90%8D%E7%A7%B0&spm=1018.2226.3001.4187

但是本人基础实在薄弱,不会修改定义变量等操作,一直没有进展。

在这里希望大家能帮帮我

这是旧数据两帧

{
    "HMDRotation": [0.703926, 0.710238, -0.00540072, -0.00461164],
    "Rechts": {
        "SensorVerbindung": "0",
        "ZeitSeitLetzterUebertragung": "993575734",
        "Position": [-358.896, -308.219, -98.9477],
        "AbstandStart": "483.317",
        "HandRotation": [-0.784519, 0.179188, -0.593474, 0.0162934],
        "UnterarmRotation": [-0.380932, -0.619327, 0.487125, 0.483756],
        "Daumen1.Rotation": [-0.619248, -0.177263, -0.659916, -0.386882],
        "Daumen2.Rotation": [-0.237731, -0.259528, -0.909868, -0.219831],
        "Daumen3.Rotation": [-0.0746174, -0.343952, -0.896722, 0.26847],
        "Zeigefinger1.Rotation": [-0.573592, 0.437912, -0.691804, -0.0262439],
        "Zeigefinger2.Rotation": [-0.709815, -0.130146, -0.484572, 0.49444],
        "Zeigefinger3.Rotation": [-0.499462, -0.520877, -0.103643, 0.6845],
        "Mittelfinger1.Rotation": [-0.635811, 0.364394, -0.667065, -0.134316],
        "Mittelfinger2.Rotation": [-0.617596, 0.39448, -0.659853, -0.166166],
        "Mittelfinger3.Rotation": [-0.602999, 0.416451, -0.653445, -0.189806],
        "Ringfinger1.Rotation": [-0.383168, 0.375543, -0.841124, -0.0686718],
        "Ringfinger2.Rotation": [-0.364709, 0.393494, -0.836861, -0.108948],
        "Ringfinger3.Rotation": [-0.350311, 0.406365, -0.832397, -0.138996],
        "Kleinfinger1.Rotation": [-0.609939, 0.318762, -0.705704, -0.168532],
        "Kleinfinger2.Rotation": [-0.593943, 0.347659, -0.696806, -0.202196],
        "Kleinfinger3.Rotation": [-0.581046, 0.368809, -0.689077, -0.227143]
    },
    "Links": {
        "SensorVerbindung": "0",
        "ZeitSeitLetzterUebertragung": "1000",
        "Position": [195.547, -1031.64, 89.684],
        "AbstandStart": "1053.83",
        "HandRotation": [0.0250686, -0.015401, -0.986025, 0.163891],
        "UnterarmRotation": [0.5262, 0.346711, 0.739709, 0.235777],
        "Daumen1.Rotation": [0.599163, 0.616007, -0.501473, 0.100178],
        "Daumen2.Rotation": [0.853174, 0.416197, -0.309322, -0.0562653],
        "Daumen3.Rotation": [0.674421, 0.668043, -0.311014, 0.0460063],
        "Zeigefinger1.Rotation": [-0.226818, -0.0592333, -0.970132, 0.0621247],
        "Zeigefinger2.Rotation": [-0.196516, -0.127815, -0.900898, 0.365237],
        "Zeigefinger3.Rotation": [-0.160346, -0.17101, -0.78774, 0.569633],
        "Mittelfinger1.Rotation": [-0.293586, -0.00958916, -0.939864, 0.174189],
        "Mittelfinger2.Rotation": [-0.273171, -0.107993, -0.826138, 0.480813],
        "Mittelfinger3.Rotation": [-0.236599, -0.174086, -0.676206, 0.675597],
        "Ringfinger1.Rotation": [-0.24806, 0.0545293, -0.965117, 0.0633462],
        "Ringfinger2.Rotation": [-0.245159, 0.066368, -0.967045, 0.0169688],
        "Ringfinger3.Rotation": [-0.242611, 0.0751481, -0.967029, -0.0178458],
        "Kleinfinger1.Rotation": [-0.391294, 0.00663947, -0.900924, 0.187488],
        "Kleinfinger2.Rotation": [-0.386773, -0.059679, -0.856197, 0.337256],
        "Kleinfinger3.Rotation": [-0.376041, -0.108391, -0.806344, 0.443424]
    },
    "Zeitstempel": "12:45:36:43:977"
} {
    "HMDRotation": [0.703548, 0.710609, -0.00559339, -0.00485012],
    "Rechts": {
        "SensorVerbindung": "1",
        "ZeitSeitLetzterUebertragung": "0",
        "Position": [58.9173, -964.923, 12.5508],
        "AbstandStart": "966.802",
        "HandRotation": [-0.7845, 0.179188, -0.5935, 0.0162875],
        "UnterarmRotation": [-0.294097, -0.902831, -0.0249993, 0.312672],
        "Daumen1.Rotation": [-0.619226, -0.177275, -0.659936, -0.386877],
        "Daumen2.Rotation": [-0.237702, -0.259535, -0.909876, -0.219822],
        "Daumen3.Rotation": [-0.0745881, -0.343943, -0.896724, 0.268481],
        "Zeigefinger1.Rotation": [-0.620494, -0.484897, -0.445781, 0.425674],
        "Zeigefinger2.Rotation": [-0.564308, -0.549268, -0.397039, 0.471464],
        "Zeigefinger3.Rotation": [-0.517769, -0.593341, -0.357382, 0.502192],
        "Mittelfinger1.Rotation": [-0.639201, -0.392591, -0.392215, 0.532464],
        "Mittelfinger2.Rotation": [-0.452782, -0.598075, -0.171849, 0.638607],
        "Mittelfinger3.Rotation": [-0.270567, -0.699642, 0.0106656, 0.661239],
        "Ringfinger1.Rotation": [-0.40195, -0.404821, -0.584591, 0.576945],
        "Ringfinger2.Rotation": [-0.250533, -0.512521, -0.368171, 0.734209],
        "Ringfinger3.Rotation": [-0.118525, -0.558029, -0.178786, 0.801653],
        "Kleinfinger1.Rotation": [-0.618678, -0.310752, -0.394771, 0.604056],
        "Kleinfinger2.Rotation": [-0.51455, -0.463214, -0.221087, 0.686912],
        "Kleinfinger3.Rotation": [-0.411932, -0.556454, -0.0797794, 0.717191]
    },
    "Links": {
        "SensorVerbindung": "0",
        "ZeitSeitLetzterUebertragung": "1047",
        "Position": [195.582, -1029.49, 89.0906],
        "AbstandStart": "1051.68",
        "HandRotation": [0.0167091, -0.0158636, -0.986249, 0.163564],
        "UnterarmRotation": [0.524893, 0.345983, 0.74027, 0.237988],
        "Daumen1.Rotation": [0.595676, 0.615013, -0.505746, 0.105457],
        "Daumen2.Rotation": [0.852646, 0.416422, -0.311466, -0.0504609],
        "Daumen3.Rotation": [0.677424, 0.664462, -0.311457, 0.0505214],
        "Zeigefinger1.Rotation": [-0.234927, -0.0589914, -0.96829, 0.0609362],
        "Zeigefinger2.Rotation": [-0.204445, -0.129896, -0.899969, 0.36243],
        "Zeigefinger3.Rotation": [-0.167709, -0.174769, -0.788026, 0.565964],
        "Mittelfinger1.Rotation": [-0.301546, -0.0104502, -0.937706, 0.172158],
        "Mittelfinger2.Rotation": [-0.280521, -0.111118, -0.82542, 0.477088],
        "Mittelfinger3.Rotation": [-0.243084, -0.178743, -0.677123, 0.671145],
        "Ringfinger1.Rotation": [-0.251178, 0.0558925, -0.964236, 0.0632883],
        "Ringfinger2.Rotation": [-0.248208, 0.0678792, -0.966162, 0.0169532],
        "Ringfinger3.Rotation": [-0.245604, 0.0767681, -0.966146, -0.0178296],
        "Kleinfinger1.Rotation": [-0.394908, 0.00575258, -0.899623, 0.186182],
        "Kleinfinger2.Rotation": [-0.390129, -0.0615198, -0.85483, 0.336527],
        "Kleinfinger3.Rotation": [-0.379059, -0.110903, -0.804779, 0.443076]
    },
    "Zeitstempel": "12:45:36:85:29"
}

这是新数据两帧

{
    "handAnimDatas": [{
        "RightHandData": {
            "WristPosition": [-0.0988655, 1.32275, 0.774074],
            "WristRotation": [-0.642029, 0.130407, 0.75174, 0.0753594],
            "Thumb0Rotation": [-0.386082, 0.55192, -0.58349, 0.453722],
            "Thumb1Rotation": [-0.143621, 0.592115, -0.758698, 0.230544],
            "Thumb2Rotation": [-0.422357, 0.439137, -0.539248, 0.581365],
            "Index0Rotation": [-0.0359249, 0.469749, -0.303286, 0.828289],
            "Index1Rotation": [-0.34767, 0.317931, 0.345705, 0.811501],
            "Index2Rotation": [-0.463888, 0.0822384, 0.726614, 0.500078],
            "Middle0Rotation": [-0.103264, 0.445618, -0.32525, 0.827631],
            "Middle1Rotation": [-0.0817654, 0.450059, -0.364584, 0.811074],
            "Middle2Rotation": [-0.0655149, 0.45271, -0.393538, 0.797427],
            "Ring0Rotation": [-0.0933286, 0.209323, -0.303432, 0.92488],
            "Ring1Rotation": [-0.0831781, 0.21356, -0.347457, 0.909257],
            "Ring2Rotation": [-0.0754383, 0.216415, -0.379955, 0.896163],
            "Pinky0Rotation": [-0.103185, 0.304576, -0.253447, 0.912333],
            "Pinky1Rotation": [-0.0884533, 0.309176, -0.296927, 0.899123],
            "Pinky2Rotation": [-0.0772689, 0.312159, -0.329094, 0.887854]
        },
        "LeftHandData": {
            "WristPosition": [342.941, 613.456, -296.121],
            "WristRotation": [0, 0, 0, 0],
            "Thumb0Rotation": [0, 0, 0, 0],
            "Thumb1Rotation": [0, 0, 0, 0],
            "Thumb2Rotation": [0, 0, 0, 0],
            "Index0Rotation": [0, 0, 0, 0],
            "Index1Rotation": [0, 0, 0, 0],
            "Index2Rotation": [0, 0, 0, 0],
            "Middle0Rotation": [0, 0, 0, 0],
            "Middle1Rotation": [0, 0, 0, 0],
            "Middle2Rotation": [0, 0, 0, 0],
            "Ring0Rotation": [0, 0, 0, 0],
            "Ring1Rotation": [0, 0, 0, 0],
            "Ring2Rotation": [0, 0, 0, 0],
            "Pinky0Rotation": [0, 0, 0, 0],
            "Pinky1Rotation": [0, 0, 0, 0],
            "Pinky2Rotation": [0, 0, 0, 0]
        }
    }, {
        "RightHandData": {
            "WristPosition": [0.00372157, 1.33687, 0.351228],
            "WristRotation": [-0.641747, 0.130728, 0.751936, 0.0752602],
            "Thumb0Rotation": [-0.386077, 0.551968, -0.58334, 0.453862],
            "Thumb1Rotation": [-0.143467, 0.59211, -0.758638, 0.230848],
            "Thumb2Rotation": [-0.422222, 0.439211, -0.539043, 0.581597],
            "Index0Rotation": [-0.0355433, 0.469215, -0.30311, 0.828673],
            "Index1Rotation": [-0.346975, 0.317859, 0.345964, 0.811716],
            "Index2Rotation": [-0.463252, 0.0826063, 0.726887, 0.500209],
            "Middle0Rotation": [-0.103104, 0.445422, -0.325108, 0.827813],
            "Middle1Rotation": [-0.0816151, 0.449856, -0.36445, 0.811261],
            "Middle2Rotation": [-0.0653721, 0.452502, -0.393411, 0.797619],
            "Ring0Rotation": [-0.0931309, 0.209007, -0.303386, 0.924986],
            "Ring1Rotation": [-0.0829959, 0.213235, -0.347416, 0.909365],
            "Ring2Rotation": [-0.0752678, 0.216084, -0.379919, 0.896273],
            "Pinky0Rotation": [-0.102886, 0.304178, -0.253662, 0.91244],
            "Pinky1Rotation": [-0.0881737, 0.308764, -0.297147, 0.899219],
            "Pinky2Rotation": [-0.0770042, 0.311738, -0.329317, 0.887942]
        },
        "LeftHandData": {
            "WristPosition": [342.974, 613.456, -296.076],
            "WristRotation": [0, 0, 0, 0],
            "Thumb0Rotation": [0, 0, 0, 0],
            "Thumb1Rotation": [0, 0, 0, 0],
            "Thumb2Rotation": [0, 0, 0, 0],
            "Index0Rotation": [0, 0, 0, 0],
            "Index1Rotation": [0, 0, 0, 0],
            "Index2Rotation": [0, 0, 0, 0],
            "Middle0Rotation": [0, 0, 0, 0],
            "Middle1Rotation": [0, 0, 0, 0],
            "Middle2Rotation": [0, 0, 0, 0],
            "Ring0Rotation": [0, 0, 0, 0],
            "Ring1Rotation": [0, 0, 0, 0],
            "Ring2Rotation": [0, 0, 0, 0],
            "Pinky0Rotation": [0, 0, 0, 0],
            "Pinky1Rotation": [0, 0, 0, 0],
            "Pinky2Rotation": [0, 0, 0, 0]
        }
    }]
}

  • 写回答

5条回答 默认 最新

  • IT_心如止水 2021-08-25 19:10
    关注

    私信,咱俩细聊一下需求,今晚给你搞定

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 9月2日
  • 已采纳回答 8月25日
  • 创建了问题 8月25日

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R