Python3 操作excel读写报错 AttributeError: 'Book' object has no attribute 'save'(write,value)

Python3 对excel进行读取操作,读取完不需要save;有写入操作才需要save

1.看如下脚本:

#!/usr/bin/env python3
#coding=utf-8

import datetime,platform,time,os,sys,stat,re,linecache
from urllib import request
import urllib.request
import shutil,xlrd,xlwt,openpyxl
from xlutils.copy import copy
#from openpyxl import load_workbook
wbb=xlrd.open_workbook(r’Top_500_of_PE_result.xls’)
#wbb1=copy(wbb)
wss=wbb.sheet_by_index(0)
print(wss.name,wss.nrows,wss.ncols)
wbb.save(“Top_500_of_PE_result.xls”)
运行结果如下:

RESTART: C:\3.Work\0.study\4.Python\201906\201906_auto_find_top500\20190628\python_xlsx20190628.py
PE_foundation_value 14 5
Traceback (most recent call last):
File “C:\3.Work\0.study\4.Python\201906\201906_auto_find_top500\20190628\python_xlsx20190628.py”, line 15, in
wbb.save(“Top_500_of_PE_result1.xls”)
AttributeError: ‘Book’ object has no attribute ‘save’
因为使用了xlrd模块操作,所以并不需要save,否则,会报错。同样在这里使用write也会有同样报错!!!

你可能感兴趣的:(Python)