Python借鉴-python-操作excel
2021-03-18 00:27
标签:open() charm com 格式 xlsx sheet 复制 from pycharm
1)用管理员身份打开dos命令行----pip install openpyxl
2)用管理员身份运行 pycharm
复制代码
存到excel里面,python去操作excel文件
只支持这种后缀,xlsx ,openpyxl只支持这种格式
pip install openpyxl
from openpyxl import load_workbook
1:打开文件,加载用例薄
wb=load_workbook("D:\test.xlsx") #和file=open()差不多
2:定位表单
sheet = wb[‘test_sheet1‘] #test_sheet1是sheet表的名字
3:定位单元格
res1 = sheet.cell(row=1, column=1).value
print(res1)
‘‘‘
print(sheet.max_column)
print(sheet.max_row)‘‘‘
res2 = sheet.cell(row=2, column=2).value
print(res2)
‘‘‘print(sheet.max_column)
print(sheet.max_row)‘‘‘
res3 = sheet.cell(row=3, column=3).value
print(res3)
‘‘‘print(sheet.max_column)
print(sheet.max_row)‘‘‘
复制代码
参考文档:https://www.cnblogs.com/wuzm/p/11977694.html 感谢博主
Python借鉴-python-操作excel
标签:open() charm com 格式 xlsx sheet 复制 from pycharm
原文地址:https://www.cnblogs.com/6413dls/p/13957573.html
文章标题:Python借鉴-python-操作excel
文章链接:http://soscw.com/index.php/essay/65548.html