五种数据容器
1.list(列表)
2.tuple(元组)
3.str(字符串)
4.set(集合)
5.dict(字典)
一.list(列表)
定义空列表可以使用[]
列表中的元素的是有上限的,只是比较大基本上都可以满足日常使用...}
print(f"set的去重测试结果为 - {set}")
# 3.set.add(元素) - 添加集合
set = {1,2,3}
print(f"添加前的set为 - {set}")
set.add...- {len(set)}")
# 11.集合的遍历操作
# 因为集合不支持下标索引所以集合不能使用while进行遍历,只能使用for
set = {1,2,3}
for msg in set:...(f"dict已被清空 - {msg}")
# 7.dict.keys() - 获取字典内的全部key,主要用于for循环遍历中
dict = {1:"a",2:"b",3:"c"}
msg = dict.keys...()
print(f"dict中的key有 - {msg}")
# 8.for遍历dict
dict = {1:"a",2:"b",3:"c"}
for key in dict.keys():