2、python常用基础类型介绍

1、字符串类型str

word='helloworld'
print(type(word),word)
  <class 'str'> helloworld

2、列表类型 list

l=[1,2,3,4]
print(type(1),l)
  <class 'int'> [1, 2, 3, 4]

3、元祖类型 tuple

t=(1,2,3,4)
print(type(t),t)  
  <class 'tuple'> (1, 2, 3, 4)

4、字典类型 dict

dic={"a":1,'b':2}
print(type(dic),dic)
  <class 'dict'> {'a': 1, 'b': 2}

5、bool类型 

 在所以的bool值得类型中,只有两个答案,True (真)、 False(假)

a=1
b=2
print(a < b)
  True
print(a > b)
  False




猜你喜欢

转载自www.cnblogs.com/wyf-577513827/p/9121718.html