Python error ' str ' object is not callable

Source: Internet
Author: User

>>> x=1.235

>>> Int (x)

1
>>> str= "FSGAVFDBAFDBNTSBGBT"
>>> Len (str)
19
>>>
>>> x=987456123
>>> Str (x)

Will error ' str ' object is not callable.

STR () is a system-brought, you can not use it when you define a different variable called STR, this will conflict.

Change the custom str variable to a different 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, just to implement a special way of __call__ ().

So, when the error XXX is not callable, it is likely that you are calling a variable or object that cannot be called, specifically, you call the function, the way the variable is wrong.

Python error ' str ' object is not callable

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.