python练习程序(读写文件)

import os

file=open("123.txt","r")
for line in file.readlines():
    print line,
file.close()

file=open("123.txt","w")
file.write("sdfsdfsdf")
file.close()

file=open("123.txt","a")
file.write("erertyerty")
file.close()

file=open("123.txt","r")
for line in file.readlines():
    print line,
file.close()

你可能感兴趣的:(python)