Home python Error of types “NoneType object is not callable”

Error of types “NoneType object is not callable”

Author

Date

Category

Good evening.
I would like to know how to get rid of this error.

itemDesc.replace (';', '')

An error occurs on this line, this variable contains the html code.
An error occurs:

TypeError: ‘NoneType’ object is not callable


Answer 1, authority 100%

We must trust Python.
Your itemDesc object is of type NoneType . There is no replace method for it
You write that the variable contains html code, but apparently this is not the case.
Check the type and act depending on the result.

& gt; & gt; & gt; type (itemDesc)

http://docs.python.org/library/types.html#types.NoneType


Answer 2

I already figured it out, I understood that you need to declare a variable as a string, but for some reason this option did not work

itemDesc = str (itemDesc)

Suggest like this:

itemDesc = itemDesc .__ str __ (). replace ('', '') & lt; br & gt;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions