栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python Type Conversion or Type Casting

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python Type Conversion or Type Casting

In Python, we can convert one type of variable to another type. This conversion is called type casting or type conversion.

In casting, we convert variables declared in specific data types to the different data types.

Python performs the following two types of casting.

Implicit casting: The Python interpreter automatically performs an implicit type conversion, which avoids loss of data.

Explicit casting: The explicit type conversion is performed by the user using built-in functions.

To perform a type casting, we are going to use the following built-in functions:

  1. int(): convert any type variable to the integer type.
  2. float(): convert any type variable to the float type.
  3. complex(): convert any type variable to the complex type.
  4. bool(): convert any type variable to the bool type.
  5. str(): convert any type variable to the string type.

In type casting, data loss may occur because we enforce the object to a specific data type.

I'd like to introduce each of them respectively in the following articles.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/884345.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号