当前位置:主页 > 软件编程 > Python代码 >

python覆盖写入,追加写入的实例

时间:2021-02-12 08:51:46 | 栏目:Python代码 | 点击:

追加写入:

# -*- coding:utf-8 -*-

# a 指定打开文件的模式,a为追加  r为只读

a=open('test.txt', 'a')

a.write('追加写入')

a.close()

 

f=open('test.txt', 'r')

print f.read()

覆盖写入:

a=open('test.txt', 'w')

您可能感兴趣的文章:

相关文章