#!/usr/bin/env python
#!/usr/bin/env python
#coding: utf-8
# Auth Or: Cool
Purpose: File action class
# created:2011/1/1
06
#声明一个字符串文本 &N Bsp
poem= '
programming is fun test
When the work is done
One if You are wanna make your work also fun:
use python!
'
#创建一个file类的实例, mode Thought: Read-only mode (' R '), write mode (' W '), Append mode (' a ')
F=file (' poem.txt ', ' a ') #open for ' W ' riting
F.write ( Poem) #写入文本到文件 write text to file
F.close () #关闭文件 close the file
18
#默认 is a read-only mode
f=file (' poem.txt ')
# If no # is specified, ' r ' ead the mode is assumed by DEFAULT&N Bsp
While true:
Line=f.readline () #读取文件的每一个行
-If Len (line) ==0: # Zero Length I Ndicates eof
break
Print line, #输出该行
#注意, because the content read from the file has ended with a newline character, we use commas on the output statement to eliminate word wrapping. &NBSP
28
#Notice comma to avoid automatic newline added by python
F.close () #close the file
31
#帮助
???