代码拉取完成,页面将自动刷新
# 使用 open 打开文件
# f = open("e:/note.txt", "r")
# print(f)
# print(type(f))
#
# f.close()
# flist = []
# count = 0
# while True:
# f = open("e:/note.txt", "r")
# flist.append(f)
# count += 1
# print(f"打开文件的个数 {count}")
# flist = []
# count = 0
# while True:
# f = open("e:/note.txt", "r")
# flist.append(f)
# count += 1
# f.close()
# print(f"打开文件的个数 {count}")
# 写文件(直接写)
# f = open("e:/note.txt", "w")
# f.write("hello")
# f.close()
# 写文件(追加写)
# f = open("e:/note.txt", "a")
# # f.write(", world") # 在末尾追加写入
# f.write("\nbibubibu") # 另起一行写入
# f.close()
# 读文件
# 使用 read 读取文件内容, 指定读几个字符
# f = open("e:/note.txt", "r", encoding='utf8') # 指定读取的格式为 utf8 -> 需要保证读取的格式与文件的格式相一致
# ret = f.read(2)
# f.close()
# print(ret)
# 使用 read 读取文件内容, 指定读几行
# f = open("e:/note.txt", "r", encoding="utf8")
# for line in f:
# print(f"line = {line}", end="")
# f.close()
# 使用 read 读取文件内容, 读取文件中的所有内容
# f = open("e:/note.txt", "r", encoding="utf8")
# ret = f.readlines()
# print(ret)
# f.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。