【问题标题】:zip Cuts off After First Letterzip 在第一个字母后切断
【发布时间】:2019-03-18 21:19:50
【问题描述】:

我正在尝试运行以下代码:

def by_primary_key(table, key, fields) -> object:
    key_columns = get_key_columns(table, key )
    print("key columns in get by primary key " , key_columns)
    print("key, " , key )
    zip_it = list(zip(key_columns, key))
    print("zip_it", zip_it )
    dictt = dict(zip_it)
    print("dict", dictt)

我想要的 zip_it 输出是:[('playerID', 'willite01')]

但程序产生的输出是: 通过主键 ['playerID'] 获取中的键列

键,willite01

zip_it [('playerID', 'w')]

dict {'playerID': 'w'}

我哪里错了?

【问题讨论】:

    标签: python database csv dictionary zip


    【解决方案1】:

    以下工作

    key_columns = get_key_columns(table, key )
    lst = []
    lst.append(key)
    tmp = dict(zip(key_columns, lst))
    result = find_by_template1(table, tmp, fields)
    return result
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-01
      • 2017-01-25
      • 2022-11-04
      • 1970-01-01
      • 1970-01-01
      • 2012-03-20
      • 1970-01-01
      相关资源
      最近更新 更多