【Python】读取文件(1)

今日练习:

 

今日阅读:

 

【Python open读写文件实现脚本】http://www.jb51.net/article/15709.htm

【The Python Standard Library】http://docs.python.org/2/library/

 

  • close -- Closes the file. Like File->Save.. in your editor.
  • read -- Reads the contents of the file, you can assign the result to a variable.
  • readline -- Reads just one line of a text file.
  • truncate -- Empties the file, watch out if you care about the file.
  • write(stuff) -- Writes stuff to the file.

 

1.

target = open(filename, 'w')

【What does 'w' mean?It's really just a string with a character in it for the kind of mode for the file. If you use 'w' then you're saying "open this file in 'write' mode", thus the 'w' character. There's also 'r' for "read", 'a' for append, and modifiers on these.】

posted on 2012-11-07 20:59  Jenny_HUI  阅读(200)  评论(0编辑  收藏  举报

导航