我正在从postgres表读取数据,我正在读取的其中一个字段具有以下数据:
'1', '1', '203316-01', 'Outdoor Bistro Infrared Heated Table'
遍历字典,我将这些值赋给一个属性sg_item_list,然后使用这个字段创建一个列表。
['1', '1', '203316-01', 'Outdoor Bistro Infrared Heated Table']使用以下python脚本:
cnt = 0
new_dsL = []
for sg_item in dsL:
sg_itemL = eval(sg_item.sg_item_list)
print 'list printed', sg_itemL
for i_row in sg_itemL:
cnt += 1
print 'printing list', cnt, i_row
#print 'debugg i_row:',i_row[2]
if len(i_row) >= 3 : #and i_row[2] in boD:
print 'debugg:',i_row[2]
sg_item.sg_bo_ind = 'True'
new_dsL.append(sg_item)
dsL = new_dsL我遍历了列表,但得到了不正确的结果,如下所示:
xxxx@xxxx /cygdrive/c/Reports/SI_Reconciliation_Reporting
$ /cygdrive/c/Python27-64/python.exe ./bin/si_under_dev_rpt-drop-ship-orders-last-60-days.py
list printed ['1', '1', '203316-01', 'Outdoor Bistro Infrared Heated Table']
printing list 1 1
printing list 2 1
printing list 3 203316-01
debugg: 3
printing list 4 Outdoor Bistro Infrared Heated Table
debugg: t
RPT: Create the DS Last 60 Days Report. version: R1
我应该看到203316-01而不是3或t。
我做错了什么?
发布于 2015-03-26 04:33:53
你在你的调试行中建立了索引,得到了"203316-01“和"Outdoor Bistro红外线加热表”。
https://stackoverflow.com/questions/29265650
复制相似问题