python中的读写文件

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
fo=open("C:\Users\Administrator.USER-20190123WB\Desktop\wenjian1.txt","a")
s=fo.write("我爱我的祖国~\n"
           "我爱北京天安门~\n"
           "我爱随风飘扬的五星红旗~")
# fo.close()
f=open("C:\Users\Administrator.USER-20190123WB\Desktop\wenjian1.txt","r")
s1=f.read()
print(s1)
f.close()

猜你喜欢

转载自blog.csdn.net/u012613144/article/details/88365576