Python type conversion function

Source: Internet
Author: User

Python provides built-in functions that can convert a value from one type to another.

1. The INT function converts any value that can be converted to an integer to an integral type. int can convert a floating-point number to an integer, but it does not do a rounding operation, but instead discards the fractional part directly.

>>> int ('+')32>>> int (3.9999)3

2. The float function converts integers and strings to floating-point numbers.

>>> Float (+)32.0>>> float ('3.14159')3.14159

3. The STR function converts the argument to a string.

>>> Str (+)' +'>>> str (3.14159)'  3.14159'

Python type conversion function

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.