码迷,mamicode.com
首页 >  
搜索关键字:readlines    ( 570个结果
HackerRank - "Building a Smart IDE: Identifying comments"
import reimport ioimport sysinput_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')s = input_stream.readlines()s = "\n".join(s)pc = '(//.*...
分类:其他好文   时间:2015-06-03 08:25:20    阅读次数:1717
python 点滴记录8:文件操作read、readline与readlines
python读取文件内容时,有三种方法:read()、readline()和readlines()这三种方法区别如下:read(...) read([size])->readatmostsizebytes,returnedasastring. Ifthesizeargumentisnegativeoromitted,readuntilEOFisreached. Noticethatwheninnon-blockingmode,lessdatathan..
分类:编程语言   时间:2015-05-29 18:29:07    阅读次数:188
使用 golang 收集系统指标
common.go ``` // copy code from github.com/shirou/gopsutil package sys import ( "bufio" "os" "strings" ) // ReadLines reads contents from file and splits them by new line. // A convenience wrapper ...
分类:其他好文   时间:2015-05-21 09:19:30    阅读次数:280
分析nginx ip地址来源
接上一篇的日志格式,我们已经筛选出了所有的IP地址、做法稍有不同。nginx正则把IP写进文件里、还是那句话数据太大我们不能写进列表里边:defgetIP(): f=open(log,‘r‘) IPdic={} forloglineinf.readlines(): matchs=p.match(logline) ifmatchs!=None: allGroups=matchs.groups(..
分类:其他好文   时间:2015-05-20 18:53:07    阅读次数:181
python set集合按行去重
s3=set() #s3=set(open(‘/home/work/ctt/20150409.uid.head‘,‘r‘).readlines()) file=open(‘/home/work/ctt/20150409.uid.head‘) for?line?in?file.readlines(): ???line=line.strip(‘\n‘) #???print?l...
分类:编程语言   时间:2015-05-05 22:06:43    阅读次数:156
Python 编写登陆接口,输入用户名密码,认证成功后显示欢迎信息,输入错误三次锁定
file=open(‘lock.txt‘).readlines()name=input(‘username:‘).strip()lock=[]foriinfile:line=i.strip(‘\n‘)lock.append(line)ifnameinlock:print(name,‘已经被锁定,请联系开户行.退出!‘)else:i=1whilei<=3:i=i+1print(‘........................‘)username=nameprint(userna..
分类:编程语言   时间:2015-04-29 17:38:18    阅读次数:587
Python中关于with open file as 的用法
最近用到python来处理文本文件了,然后需要处理文件。发现python中提供的with   open  as   这个还是用的不错的!好的,废话不多说了,看下例子: with open('./sigir_title_cizu.txt') as cizu, open('sigir_title.txt') as titles: cizuData = cizu.readlines() title...
分类:编程语言   时间:2015-04-24 09:19:56    阅读次数:841
python进行md5加密
代码函数import hashlibdef md5(str): m = hashlib.md5() m.update(str) return m.hexdigest()f = open('idfa.csv','r') result = open('test.csv','w') for line in f.readlines(): encrypt...
分类:编程语言   时间:2015-04-22 14:00:05    阅读次数:180
统计dhcpd.lease IP 地址
#!/usr/bin/envpython #coding=utf-8 importstring alist=[] lease_IP=‘‘ lease_start=‘‘ lease_end=‘‘ istatus=‘‘ MAC=‘‘ f=open(‘/var/lib/dhcpd/dhcpd.leases‘) lines=f.readlines() f.close() forlineinlines: ifline.find(‘lease‘)<>-1: lease_IP=line.split(‘\n‘)[..
分类:其他好文   时间:2015-04-20 18:49:48    阅读次数:161
thinkphp日志分割成每个请求一个文件
#!/usr/bin#coding:utf-8import os, re, errnols = os.popen('ls *.log').readlines()dirs = []lines = []for line in ls: if line.strip(): dirs.append(re....
分类:Web程序   时间:2015-03-10 15:27:20    阅读次数:281
570条   上一页 1 ... 52 53 54 55 56 57 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!