1 Star 0 Fork 0

哔卟哔卟/Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Test17.py 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
哔卟哔卟 提交于 2023-10-04 17:58 . 提交 Python 相关
# 使用 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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/p_bart/python.git
git@gitee.com:p_bart/python.git
p_bart
python
Python
master

搜索帮助