参考网页:
https://www.cnblogs.com/yhms/p/10138513.html
https://www.jb51.net/article/117515.htm


import os
from openpyxl import load_workbook

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    os.chdir("D:\Images\python_excel_test")
    workbook1 = load_workbook('test_case.xlsx')
    sheet = workbook1['test_data']
    data = sheet.cell(3, 2).value
    print(data)

    for row in sheet.rows:
        for cell in row:
            print(cell.value)

    for column in sheet.columns:
        for cell in column:
            print(cell.value)

 

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐