uple 和list 都有拆包的特性
name_tuple = ("boby1", "boby2","boby3")
user_tuple = ("boby", 29, 175, "beijing", "edu")
name, *other = name_tuple
li = ["boby1", "boby2","boby3"]
name, name2, name3 = li
name1, *other = li
print(name, name2, name3)
print(name1, other)
tuple 可以作为dict 的key,而list不可以 # 注意:tuple 中的元素是不可以修改的,当然也有可变的tuple,比如,某个元素为list,list是可变的
user_tuple_dict = {}
user_tuple_dict[user_tuple] = "boby"
print(user_tuple_dict)
# user_tuple_dict[li] = "boby1"
# print(user_tuple_dict)
tuple 中的元素是可以重复的,此点与set不同,set中的元素是不可重复的。
tuple1 = (1,1,2)
print(tuple1)