The following two errors occurred while writing the code today:
TypeError: ' Module ' object is not callable
' Xlbook '
On the Internet, found that the first error is because there are two different references in Python, import xxx and from XXX import *, the former in the code to reference the need to add the module name and the specific method or property, the method is as follows:
Import= Catchform.catchform ()
The From XXX Import * can be directly referenced by:
from Import *= Catchform ()
After solving the first error, and immediately encountered the second error, baffled the solution, my code is as follows:
class Excelchange:
"" a win32com wrapper class that encapsulates all of its methods,
Unified call
""
def _init_ (self,filename = None): #传入文件名参数, if any, Do not assign the None to filename, and then create a new
Self.xlapp = Dispatch (' Excel.Application ')
if filename:
self.filename = filename
Self.xlbook = self.xlApp.Workbooks.Open (filename)
Else:
Self.xlbook = SELF.XLAPP.WORKBOOKS.ADD ()
self.filename = '
I see, xlbook this does not have, why error, finally on the internet to find:
My _init_ is wrong, the correct writing should be __init__, there are two underline =. =
囧rz
Summary: The code still has to write very often AH =. = Especially in a company where a leader blindly believes in automation (which thinks that automation is all-rounder), it is over when it is finished.