mark下
import sys
f=open('test.txt','a+')
s= '123'
abc= '456'
print >> f, s,abc
f.close()
r 读
w 写
a 追加
本文深入探讨了Python中文件操作的两种基本方式:追加和读写。通过实例演示如何使用`open()`函数以不同的模式打开文件,并详细解释了`print()`函数与文件对象之间的交互,以及如何正确地关闭文件以避免资源泄露。
mark下
import sys
f=open('test.txt','a+')
s= '123'
abc= '456'
print >> f, s,abc
f.close()
r 读
w 写
a 追加
1318

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