码迷,mamicode.com
首页 >  
搜索关键字:readlines    ( 570个结果
login未完成
#!coding=utf8auth_file = open('user')auth_list = auth_file.readlines()auth_file.close()n = 0while n < 3: n+=1 lock = open('bad') lock_list = [] for i ...
分类:其他好文   时间:2016-08-31 20:37:15    阅读次数:143
python中read() readline()以及readlines()用法
【转自:http://www.ibm.com/developerworks/cn/linux/sdk/python/python-5/index.html#N1004E】 我们谈到“文本处理”时,我们通常是指处理的内容。Python 将文本文件的内容读入可以操作的字符串变量非常容易。文件对象提供了三 ...
分类:编程语言   时间:2016-08-31 13:56:46    阅读次数:157
tmp
# encoding: UTF-8file_name = r'C:\Users\xshi\Desktop\1.txt'AB_list = []with open(file_name) as f: content = f.readlines() AB_list.append(content)x = A... ...
分类:其他好文   时间:2016-08-19 19:08:08    阅读次数:126
Files
guava源码:Files 看一下它的调用过程 public static <T> T readLines(File file, Charset charset, LineProcessor<T> callback) throws IOException { return asCharSource( ...
分类:其他好文   时间:2016-08-17 01:19:32    阅读次数:128
使用python编写批量ping主机脚本
通过使用python,编写脚本批量ping主机,验证主机是否处于活动状态#!/usr/bin/python #auther:Jacky #date:2016-08-01 #filename:ping_ip.py importos,sys importsubprocess,cmd defsubping(): f=open("ip_list.txt","r") lines=f.readlines() forlineinlines: line=line.s..
分类:编程语言   时间:2016-08-04 11:48:57    阅读次数:2052
python语法的一些问题1
open 文件操作 python strip()函数 .read() 、readline()与readlines() split()函数 一、open 文件操作 open/文件操作 f=open('/tmp/hello','w') #open(路径+文件名,读写模式) #读写模式:r只读,r+读写,... ...
分类:编程语言   时间:2016-07-16 20:18:35    阅读次数:359
Python下用List对员工信息表进行模糊匹配
#需求用户可以模糊查询员工信息显示匹配了多少条,匹配字符需要高亮度显示#脚本内容#!/usr/bin/envpython #_*_coding:utf-8_*_ whileTrue: info=‘info.txt‘ f=file(info) search=raw_input(‘PleaseEngterYouSearchInfo:‘) forlineinf.readlines(): i=line.strip().split() q=i[..
分类:编程语言   时间:2016-07-11 01:17:21    阅读次数:196
初学python-获取网络设备配置文件接口IP信息
#!/usr/bin/python#coding=utf-8importre,sys,csvfromstringimportreplacedefInterfaceinfo(file_path,firms): withopen(file_path,‘r‘)asf: filecontext=f.readlines() iffirms==‘a10‘: splitstring_keyword=‘(^!)‘ firms_interface=‘^interface(.+)‘ ip_keyword=‘^ip..
分类:编程语言   时间:2016-07-09 22:25:30    阅读次数:1303
使用KNN对iris数据集进行分类——python
filename='g:\data\iris.csv' lines=fr.readlines()Mat=zeros((len(lines),4))irisLabels=[]index=0for line in lines: line=line.strip() if len(line)>0: list ...
分类:编程语言   时间:2016-07-03 23:23:56    阅读次数:1065
Python中fileinput模块使用
fileinput模块可以对一个或多个文件中的内容进行迭代、遍历等操作。该模块的input()函数有点类似文件 readlines()方法,区别在于前者是一个迭代对象,需要用for循环迭代,后者是一次性读取所有行。 用fileinput对文件进行循环遍历,格式化输出,查找、替换等操作,非常方便。 【 ...
分类:编程语言   时间:2016-07-03 13:01:08    阅读次数:180
570条   上一页 1 ... 45 46 47 48 49 ... 57 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!