python
主页 > 脚本 > python >

python覆盖写入,追加写入的方法

2019-06-26 | 秩名 | 点击:
本篇文章介绍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')

原文链接:https://blog.csdn.net/jpmsdn/article/details/86302312
相关文章
最新更新