[Python] A low-level error/XXX instance have no attribute ' xxx '/' module ' object is not callable

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.