我有这个基本的问题,但不能左右我的头:正确赋值
prepared_data = ([1, '7303 ', 'product1'], [2, '7304 ', 'product2'], [3, '7534 ', 'product3'], [4, '7652 ', 'product4'])
我要分配这些值,但不能得到如何妥善安排循环:
for row_num in range(2, len(prepared_data)+2):
for index in range(len(prepared_data)):
wb2_ws1.cell(row=row_num, column=1).value = prepared_data[index][0]
wb2_ws1.cell(row=row_num, column=2).value = prepared_data[index][1]
wb2_ws1.cell(row=row_num, column=3).value = prepared_data[index][2]
wb2_ws1.cell(row=row_num, column=4).value = 'John'
程序应该填写第二行的单元格。但它总是覆盖之前的所有值。感谢您的帮助
谢谢,它的工作。我不知道你可以循环这两个值 – neptunereach