元组的使用

字符串


序列


set 集合
集合的定义

集合常用功能总结:

字典


五类数据容器的特点

容器排序
list_my = [1,4,6,73,86,12,7,10]
reverse=True 代表反向排序
print(sorted(list_my, reverse=True))


文件操作

count = 0;
with open("word.txt","r",encoding="utf-8") as f:
for line in f:
# 可以去除开头结尾空格,以及换行符
line = line.strip()
words = line.split(" ")
for word in words:
if word == "itheima":
count +=1;
print(f"itheima共有{count}个")
# 第一种方式
# f = open("word.txt","r",encoding="utf-8")
# content = f.read()
# count = content.count("itheima")
# print(count)
写文件


1356

被折叠的 条评论
为什么被折叠?



