其他分享
首页 > 其他分享> > openpyxl处理excel例子

openpyxl处理excel例子

作者:互联网

import openpyxl

inv_file = openpyxl.load_workbook("inventory.xlsx")
product_list = inv_file["Sheet1"]

products_per_supplier = {}

 

print(product_list)

for product_row in range(2, product_list.max_row + 1):
    supplier_name = product_list.cell(product_row, 4).value

    if supplier_name in products_per_supplier:
        current_num_products = products_per_supplier.get(supplier_name)
        products_per_supplier[supplier_name] = current_num_products + 1
    else:
        products_per_supplier[supplier_name] = 1

print(products_per_supplier)

 

 

标签:product,openpyxl,list,excel,per,例子,products,supplier,name
来源: https://www.cnblogs.com/zhishaofei/p/16366440.html