python--file operater
来源:互联网 发布:访客统计系统源码 编辑:程序博客网 时间:2024/06/08 19:22
#!/usr/bin/env python# -*- coding: utf-8 -*-__author__ = 'Administrator'#data=open("yesterday",encoding="utf-8").read()#f=open("yesterday",encoding="utf-8")#1. f=open("yesterday2","w",encoding="utf-8")#append#f=open("yesterday2","a",encoding="utf-8")#f=open("yesterday","r",encoding="utf-8")#f=open("yesterday","r+",encoding="utf-8") #文件句柄 读写#f=open("yesterday2","w+",encoding="utf-8") #文件句柄 写读(X)#f=open("yesterday2","a+",encoding="utf-8") #文件句柄 追加读写#f=open("yesterday2","rb") #文件句柄 二进制文件f=open("yesterday2","wb") #文件句柄 二进制文件f.write("hello binary!!!!".encode())f.close()#print(f.readline())#data=f.read()#data2=f.read()#print(data)#print("---------data2-------",data2)#f.write("我爱北上广\n")#f.write("北上广不相信泪水............")#"a" is not read,but it can write'''f.write("when i was young,i listen to the radio\n")data=f.read()print(data)'''#print(f.readlines())'''for line in f.readlines(): print(line.strip())'''#low loop'''for index,line in enumerate(f.readlines()): if index==9: print('----line------') continue print(line.strip())'''#high bige'''count=0for line in f: if count==9: print('----line------') count+=1 continue print(line) count+=1''''''for i in range(5): print(f.readline())''''''print(f.tell())print(f.read(5))#print(f.readline())print(f.readline())print(f.readline())print(f.readline())print(f.tell())#回溯f.seek(0)print(f.readline())print(f.encoding)#print(f.fileno())#print(f.seekable())#print(f.readable())print(f.flush())print(dir(f.buffer))'''#从“头”开始截断#f.truncate(9)#print(f.readline())'''for i in range(3): print(f.readline())f.write("-------插入数据---------")f.write("-------插入数据---------")print(f.tell())f.seek(10)print(f.readline())f.write("second line")'''
阅读全文
0 0
- python--file operater
- class object assign operater
- PHP Comparision Operater
- 运算符(Operater)
- c++ 中operater delete和operater new重载
- 重载运算符operater用法
- python file
- Python---file
- python file
- Python file
- ES6之Spread Operater拷贝对象
- File Management in Python
- python file operate
- File Objects-python
- python - file对象
- python file operation
- python file io 详解
- python -- zip file
- Python学习笔记(4)——控制流If-else
- Codeforces Round #449 (Div. 2) B. Chtholly's request
- zoj_3819_水
- Tomcat启动项目报错:invalid LOC header (bad signature)
- mysql启动参数(/etc/my.cnf)详解汇总
- python--file operater
- Oracle中的事物
- python--函数1
- 数据库索引
- VUE框架与其他前端框架比较
- Linux特殊权限
- Android 电量优化
- 文章标题
- MAC Tensorflow安装