读取文件

my_file = open('my file.txt','r')
#读取文件 r代表智能读去
my_file = open('my file.txt','w')
#w代表既能读也能写

测试小Demo

text  = "GxsDay"
my_file = open('my file.txt','w')
my_file.write(text)
my_file.close()  

用完需要关上my_file,不然程序卡或崩溃掉

结果:

python简单读取文件案例

相关文章: