qq_43601497 2021-12-04 16:57 采纳率: 80%
浏览 329
已结题

python 循环创建多个字典

a=['oc2P70Ph14EBiLrX3jI-c138f4tg','oc2P70Gt9duc-1Km4WE4FbxUsHpU','oc2P70MfrRM5lYRVI1d1fthWh3qM','oc2P70FqFlOXON3lQsbtntY2_0Sw',
'oc2P70DTCD3mzLrHVOAhyT0nWtZY']
怎么样创建多个字典形成这样的形式
{"algo_type": "XGB","scene_id": "child_purchase", "algo_version": "20210930", "bid": "wesure","request_id": "e24a15cf","user_id": "oc2P70Ph14EBiLrX3jI-c138f4tg" }
{"algo_type": "XGB","scene_id": "child_purchase", "algo_version": "20210930", "bid": "wesure","request_id": "e24a15cf","user_id": "oc2P70Gt9duc-1Km4WE4FbxUsHpU" }
{"algo_type": "XGB","scene_id": "child_purchase", "algo_version": "20210930", "bid": "wesure","request_id": "e24a15cf","user_id": "oc2P70MfrRM5lYRVI1d1fthWh3qM" }
{"algo_type": "XGB","scene_id": "child_purchase", "algo_version": "20210930", "bid": "wesure","request_id": "e24a15cf","user_id": "oc2P70FqFlOXON3lQsbtntY2_0Sw" }
{"algo_type": "XGB","scene_id": "child_purchase", "algo_version": "20210930", "bid": "wesure","request_id": "e24a15cf","user_id": "oc2P70DTCD3mzLrHVOAhyT0nWtZY" }

  • 写回答

1条回答 默认 最新

  • 缘emo 2021-12-04 17:15
    关注
    
    a = ['oc2P70Ph14EBiLrX3jI-c138f4tg', 'oc2P70Gt9duc-1Km4WE4FbxUsHpU', 'oc2P70MfrRM5lYRVI1d1fthWh3qM',
         'oc2P70FqFlOXON3lQsbtntY2_0Sw',
         'oc2P70DTCD3mzLrHVOAhyT0nWtZY']
    n = 1
    for i in a:
        s = 'dic'.join(str(n))
        s = {"algo_type": "XGB", "scene_id": "child_purchase", "algo_version": "20210930", "bid": "wesure",
             "request_id": "e24a15cf"}
        s["user_id"] = i
        n += 1
        print(s)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 3月15日
  • 已采纳回答 3月7日
  • 创建了问题 12月4日

悬赏问题

  • ¥15 c#窗体设计器错误如何解决?
  • ¥30 征集Python提取PDF文字属性的代码
  • ¥15 如何联系真正的开发者而非公司
  • ¥15 有偿求苍穹外卖环境配置
  • ¥15 代码在keil5里变成了这样怎么办啊,文件图像也变了,
  • ¥20 Ue4.26打包win64bit报错,如何解决?(语言-c++)
  • ¥15 clousx6整点报时指令怎么写
  • ¥30 远程帮我安装软件及库文件
  • ¥15 关于#自动化#的问题:如何通过电脑控制多相机同步拍照或摄影(相机或者摄影模组数量大于60),并将所有采集的照片或视频以一定编码规则存放至规定电脑文件夹内
  • ¥20 (求远程解决)深信服vpn-2050这台设备如何配置才能成功联网?