写文件:
poem=''' program is fun using Python! ''' f=open('poem.txt','w') f.write(poem) f.close()
读文件:
f=open("poem.txt") while True: line=f.readline() if len(line)==0: break print(line) f.close()