Chinaunix首页 | 论坛 | 博客
  • 博客访问: 291946
  • 博文数量: 82
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 874
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-21 09:58
个人简介

traveling in cumputer science!!

文章分类

全部博文(82)

文章存档

2016年(13)

2015年(69)

我的朋友

分类: Python/Ruby

2015-07-14 22:52:28

1. file open:
    fd = open(N1,N2):N1:path of the file to be open like '/home/warrior/Downloads/test.txt'
                                 N2:some  choiceable parameter
                                        'r':read only   'w':write only   'r+':read and write    'a':write and will add content at the end of file
2. file read: 
    content = fd.read():read all content of the file 
    oneline = fd.readline():read one line content of the file
    lastContent = fd.readlines():read the content from current vernier to the end of the file
3. file write:
    fd.write(content):when opening in 'w' it will write content cover the original content
                                when opening in 'a' it will write content add at the end of the file but not start one new line again
    fd.writelines(content): when opening in 'w' it will write content cover the original content
                                        when opening in 'a' it will write content add at the end of the file and start one new line again
4. file close:
    fd.close():when open one file must close it as you will not use it .
5. file others:
    fd.seek(number):set the vernier of the file
    
















阅读(996) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~