1.打开文件:
f = open("xx.txt","r+") //the "r+" can allow you to read and write the file , "r" can only allow you to read it
2.写入文件:
my_file.write(anything you want but in String formation) // it can only be used when you are allowed to write
3.读文件:
my_file.read() // the returned value will be the content of the text
4.关闭文件:
my_file.close()
5.可以查看closed属性判断文件是否关闭,如果为True,则表示文件已经关闭,如果为False则表示文件未关闭。