ikongXY

一.python的基本数据类型

1.数字(Number)

有int(整型),float(浮点型),bool(布尔),complex(复数)

2.字符串(String)

a="123"

3.列表(List)

a=[1,2,\'apple\']

4.元组(Tuple)

a=(1,\'apple\',2.23)

5.集合(Set)

a={1,\'apple\',2.33}

6.字典(dictionary):键值对形式

a={"name":"Tom","age":13}

不可变数据:数字,字符串,元组

可变数据:列表,集合,字典

二.类型转换

1.list-->set

l1=[1,2,3]

set=set(l1)

2.tuple-->set

t1=(1,2,3)
s1=set(t1)

3.set-->list

 

s1={1,2,3}
l1=list(s1)

4.set-->tuple

s1={1,2,3}
t1=tuple(s1)

 

分类:

技术点:

相关文章:

  • 2021-04-19
  • 2021-12-17
  • 2021-12-09
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-24
  • 2021-12-16
  • 2021-08-29
相关资源
相似解决方案