-1
当在python中使用cx_oracle模块时,当我运行查询并打印输出时,它将它作为元组对象。然而,我想输出作为一个字典对象,它整齐地: {,'',,'',,'',}使用cx_Oracle转换查询输出到冠词对象
有一个快速的事情,我可以做到这一点?
当在python中使用cx_oracle模块时,当我运行查询并打印输出时,它将它作为元组对象。然而,我想输出作为一个字典对象,它整齐地: {,'',,'',,'',}使用cx_Oracle转换查询输出到冠词对象
有一个快速的事情,我可以做到这一点?
我想出了一个方法来做到这一点。下面是相关的代码片段:
column_name = [column1,column2,column3]
for row in cur:
list_row = list(row) # convert the tuple row to a list type.
final = zip(column_names,list_row) # zip the two lists.
dict_final = dict(final) # Convert the resulting final list to a dictionary.
我不知道是否有更好的方法来做到这一点,但这就是我想出的。