1.bool
在python里面哪些值是false:
0 “” [] () {} None False
t = True
print(type(t))
i = 123
print(type(i))
f1 = 1.23
print(type(f1))
f2 = 1e10
print(f2)
print(type(f2))
4.str
字符串是不可改变的,字符串做了一些操作后,会生成一个新的字符串
s = "abc"
print(type(s))
c = 1+2j
print(c)
print(type(c))
6.tuple
只有一个元素的tuple,()中需加个",",不然会被当作元素的类型,而不是tuple类型
t = (1,2,3)
print(type(t))
t = (1)
print(type(t))
t = (1,)
print(type(t))
l = [4,5,6]
print(l)
print(type(l))
d = {"a":1,"b":2}
print(d)
print(type(d))
s = {1,2,3}
print(s)
print(type(s))
不可变集合set
set和frozenset的区别:frozenset没有add/update/remove等属性
t = frozenset('bookshop')
print(t)
print(type(t))