【问题标题】:Get first element as index to update the rest of the elements within the list获取第一个元素作为索引以更新列表中的其余元素
【发布时间】:2021-03-29 23:04:28
【问题描述】:

This is my web output using flask

registrant_record = [['1', 'James Dommenick Asaria', 'bluesmooth22@gmail.com', '09057367450', 'reg'], ['2', 'Dominador Sultan', 'princessaming@gmail.com ', '09363319670', 'reg']]

我想在点击更新按钮时获取第一个元素。

【问题讨论】:

    标签: python flash


    【解决方案1】:
        registrant_record = [['1', 'James Dommenick Asaria', 'bluesmooth22@gmail.com', '09057367450', 'reg'], ['2', 'Dominador Sultan', 'princessaming@gmail.com', '09363319670', 'reg']]
        registrant_dict={}
        for i in registrant_record:
            registrant_dict[int(i[0])]=i[1:]
    
    
        print(registrant_dict[1])
        output
        ['James Dommenick Asaria', 'bluesmooth22@gmail.com', '09057367450', 'reg']
    
       ##### if you want just the first name ####
        registrant_record = [['1', 'James Dommenick Asaria', 'bluesmooth22@gmail.com', '09057367450', 'reg'], ['2', 'Dominador Sultan', 'princessaming@gmail.com', '09363319670', 'reg']]
        registrant_dict={}
        for i in registrant_record:
            # you want to get the first change i[1] or second element i[2]
            registrant_dict[int(i[0])]=i[1]
        
        print(registrant_dict[1])
        output
        ['James Dommenick Asaria']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      • 2013-12-03
      • 1970-01-01
      • 1970-01-01
      • 2019-05-11
      • 2019-04-19
      相关资源
      最近更新 更多