python excel写入 openpyxls

xlsx_file = "test.xlsx"
wb = openpyxl.Workbook(xlsx_file)
ws = wb.active
ws["A1"]="hello world"
ws["A2"]="this is test"
  • 上种方法 写入文件,会覆盖打开前的内容
xlsx_file = "test.xlsx"
wb = openpyxl.load_workbook(xlsx_file)
ws = wb.active
ws["A1"]="hello world"
ws["A2"]="this is test"
  • 这种方法是不会覆盖的

posted on 2018-07-21 20:03  游荡的鱼  阅读(1887)  评论(0编辑  收藏  举报

导航