python 常用读取文件调用方法
2017-02-08 00:00
316 查看
import os
def readfile():
line=open('d:\\yangqiang\\cesi\\test.txt','r')
datas=[]
try:
while 1:
lines=line.readline()
if not lines:
break
data=lines.lstrip()
if data.startswith('#'):
continue
datas.append(data)
finally:
line.close()
return datas
def readfile():
line=open('d:\\yangqiang\\cesi\\test.txt','r')
datas=[]
try:
while 1:
lines=line.readline()
if not lines:
break
data=lines.lstrip()
if data.startswith('#'):
continue
datas.append(data)
finally:
line.close()
return datas
相关文章推荐
- perl正则表达式,文件读取常用方法
- python 读取配置文件方法
- C#读取XML文件常用的几种方法
- Python使用xlrd读取Excel格式文件的方法
- python中readline判断文件读取结束的方法
- DotNet调用WindowsAPI读取INI配置文件方法
- Java读取properties配置文件常用方法
- python读取文件方法
- python文件目录操作常用方法总结
- 在Python常用模块I如何打开相关文件的方法
- 从 stdin 读取输入的C程序示例 && python脚本调用可执行文件
- 在python中调用dll,并将dll以及python合并打包成一个exe文件的方法
- python计算文件的行数和读取某一行内容的实现方法
- python分割文件的常用方法
- java中properties文件的常用读取方法
- Java读取.properties资源文件的常用2种方法
- python下载文件的几种常用方法
- Makefile文件中调用python文件及perl文件的方法
- Python使用xlrd读取Excel格式文件的方法
- python中readline判断文件读取结束的方法