帮帮我,没学过这个语言,一样的吗陪

如下程序:
f = open('file.txt', 'w')
f.write('Test file is python.')
f.close()
程序执行后,file.txt的内容是();如果是如下
程序:
f = open('file.txt', 'a')
f.write('Test file is python.')
f.close()
程序执行后,file.txt的内容是()

f = open('file.txt', 'w')
f.write('Test file is python.')
f.close()
#结果是
Test file is python.
f = open('file.txt', 'a')
f.write('Test file is python.')
f.close()

#结果是
Test file is python.
Test file is python.

https://blog.csdn.net/ztf312/article/details/47259805

'w'就是完全覆盖,文件之前的内容统统擦除。
'a'就是append,跟在文件内容后面添加新的内容。

'w' 模式是清除文件原来的内容重新写, 'a' 模式是在文件末尾追加写入

为Python语言程序
w代表只写不读,第一个程序内容应为Test file is python.
a代表读写,也可以写入,故内容依然为Test file is python.(前提是远原文档无内容,有内容则追加)