【发布时间】:2018-11-14 19:16:44
【问题描述】:
我试图让我的数组打印它的所有元素,但它只产生一个。我尝试注释掉“for row”部分的不同部分,它表明它们有效。它总是会出一个。任何帮助将不胜感激,谢谢。
wA = csv.reader(warehouse_A)
next(wA, None) ## skips the header
wB = csv.reader(warehouse_B)
next(wB, None) ## skips the header
wC = csv.reader(warehouse_C)
next(wC, None) ## skips the header
wD = csv.reader(warehouse_D)
next(wD, None) ## skips the header
a_itemno = [] ## empty arrays for the item number of the warehouse to be placed
a_descripton = [] ## empty arrays for the item descripton of the warehouse to be placed
a_value = [] ## empty arrays for the item value of the warehouse to be placed
b_itemno = []
b_descripton = []
b_value = []
c_itemno = []
c_descripton = []
c_value = []
d_itemno = []
d_descripton = []
d_value = []
for row in wA: ## places the 1st row on the spreadsheets into a new array
a_itemno.append(row[0])
for row in wB:
b_itemno.append(row[0])
for row in wC:
c_itemno.append(row[0])
for row in wD:
d_itemno.append(row[0])
for row in wA: ## places the 2rd row on the spreadsheets into a new array
a_descripton.append(row[1])
for row in wB:
b_descripton.append(row[1])
for row in wC:
c_descripton.append(row[1])
for row in wD:
d_descripton.append(row[1])
for row in wA: ## places the 3rd row on the spreadsheets into a new array
a_value.append(row[2])
for row in wB:
b_value.append(row[2])
for row in wC:
c_value.append(row[2])
for row in wD:
d_value.append(row[2])
new_wA = [[a_itemno], [a_descripton], [a_value]] ## new array that only prints one element
print (new_wA)
我正在寻找的输出是: [[[废话,废话,废话,],[废话,废话,废话],[废话,废话,废话]],[[废话,废话,废话,],[废话,废话,废话],[废话,废话] ,废话]],[[废话,废话,废话,],[废话,废话,废话],[废话,废话,废话]]]]
我得到的只是: [[[废话,废话,废话,],[废话,废话,废话],[废话,废话,废话]],[[]],[[]]]
【问题讨论】: