码迷,mamicode.com
首页 > 编程语言 > 详细

python类型强转&二级容器

时间:2019-03-16 16:46:16      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:str   com   set   dict   number   --   元祖   complex   关于   

Number 类型强转

int :          ---->>>          float,  bool,  complex,  str

Float :        ---->>>              int(舍弃小数位),  bool,  complex, str

Complex :  ---->>>                str,  bool

Bool :          ---->>>               str,  int, float

 

容器类型强转:

Str :       <<<----              Number,  list,  set,  dict,  tuple

List:       <<<----                str, set, dict, tuple

Tuple     <<<----                  str, list, dict, set

Set         <<<----              str, list, tuple, dict (相同的值, 自动去重)

Dict: 二级列表, 二级元祖, 二级集合(无序, 不推荐),  二级元素若是字符串那么就只能有两个字符

 

 

关于二级容器的问题:

二级容器:  自己本身是一个容器,里面的元素还是一个容器类型数据

等长二级容器:  里面都是容器类型数据,每个容器里面元素个数都一样

强转字典必须是等长的二级容器,并且里面元素的个数是2个

python类型强转&二级容器

标签:str   com   set   dict   number   --   元祖   complex   关于   

原文地址:https://www.cnblogs.com/caihuajiaoshou/p/10542879.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!