python overwrites appends written instances

  • 2021-07-03 00:27:55
  • OfStack

Append write:


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

# a  Specifies the mode in which the file is opened, a For append   r Be read-only 

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

a.write(' Append write ')

a.close()

 

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

print f.read()

Overwrite write:


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

Related articles: