首页
mac
it
登录
6mi
u
盘
搜
搜 索
it
python在文件最后一行添加
python在文件最后一行添加
mac
2025-01-19
59
with
open
(
"D:\\test.txt"
,
encoding
=
"utf-8"
,
mode
=
"a"
)
as
file
:
file
.
write
(
"older driver"
)
mode=“w”,写模式,会重写文件;mode=“a”,追加模式,会在文件末尾添加数据。
函数调用文件时需要在每个函数中都打开关闭文件,而不是打开一次,都可以用!
转载请注明原文地址: https://mac.8miu.com/read-499701.html
最新回复
(
0
)