python file reads: Error encountered and solutions

Question one:

TypeError: 'str' object is not callable

cause:

The error TypeError: 'str' object is not callable literally meaning: str is not called by the system,

Actually, the reason is: you're calling variables or objects that can not be invoked, specific performance is what you call a function, variables with errors.

example:

    filePath=kwargs['path']
  filePathStr=str(filePath)

That is their own is in use keyword arguments passed Senate pass over time what type, what type is passed over, that is the type of string filePath has always been, but I also use the str () function to act on him, that is the problem, the function call error!

 

Question two:

IndentationError: unindent does not match any outer indentation level

The reason: the code align the new Python syntax is not supported, the mix of TAB and spaces. Therefore, the above error message appears this error

  For this error, the most common cause is indeed not aligned

  Or mix the TAB key and spacebar

 

 

Question three:

TypeError: write() takes no keyword arguments

df.write (Content, the MODE = " w + " , encoding = " UTF-8 " )
 # Of particular note is the time to write content to a python file is just a parameter to those other mode, encoding, etc. are all in the open () when the set! !

 

The reason: typeerror: write () does not accept keyword arguments, because the write () method accepts a parameter has only one is to write to the file, so it will not have other parameters, so if many parameters, it will the problem

Guess you like

Origin www.cnblogs.com/isme-zjh/p/11605298.html