def read(filename,r_content):
# 读
file = open(filename,'r')
r_content = file.read()
file.close()
print(r_content)
def write(filename,w_content):
# 写
file = open(filename,'w')
file.write(w_content)
file.close()
print('写入')
filename = '日记'
w_content = '+1'
write(filename,w_content)
print('读')
filename = '日记'
r_content = ''
read(filename,r_content)
06-27
1689
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
03-06
613
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)