python error 'str' object is not callable

  >>> x=1.235

  >>> int(x)

  1
  >>> str="fsgavfdbafdbntsbgbt"
  >>> len(str)
  19
  >>>
  >>> x=987456123
  >>> str(x)

       The error 'str' object is not callable will be reported.

  str() is built-in by the system, you cannot define another variable called str when you use it, it will conflict.

  Change the custom str variable to another name, str1, and the code passes.

 

  In Python, a function is actually an object, and all functions are callable objects. A class instance can also become a callable object by implementing a special method __call__().

  Therefore, when the error XXX is not callable occurs, it is very likely that you are calling a variable or object that cannot be called. The specific manifestation is that you are calling functions and variables in the wrong way.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324934479&siteId=291194637