python excel写入 openpyxls

Posted 游荡的鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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"
  • 这种方法是不会覆盖的

以上是关于python excel写入 openpyxls的主要内容,如果未能解决你的问题,请参考以下文章