zip在第一个字母后切断

时间:2018-10-14 06:00:03

标签: python database csv dictionary zip

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

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'}

我要去哪里错了?

1 个答案:

答案 0 :(得分:0)

以下方法有效

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
相关问题