直接创建时
list1 = ["hello","world"]
tuple1 = ("t1","t2")
dirt1 = {"d1":15, "d2":20}
set1 = {'strive','daniel'}
print("list1:",type(list1))
print("tuple1:",type(tuple1))
print("dirt1:",type(dirt1))
print("set1:", type(set1))
运行结果:
可以看出:
- [ ]定义的是list类型
- ( )定义的是tuple类型
- { }定义时
- 有value值时,为dirt
- 无value值时,为set