python作业2

来源:互联网 发布:js 数组存在元素 编辑:程序博客网 时间:2024/05/19 02:01

###正则表达式########


#!/usr/bin/env python

#coding=utf-8
import re
strin=raw_input("please input match str:")
patt=r"\bwww\.\w+\.[com|edu|net]*"
m=re.findall(patt,strin)

print m




######文件######

#!/usr/bin/env python
#coding=utf-8
filename1=raw_input("input the file1 name:")
f1=open(filename1,'r')
filename2=raw_input("input the file2 name:")
f2=open(filename2,'r')
row=0
for fa,fb in zip(f1.readlines(),f2.readlines()):
    row+=1
    if fa==fb:
        continue
        
    else:
        col=0
        for a,b in zip(fa,fb):
            if a==b:
                col+=1        
            else:
                print row,col
                break
        break
f1.close()
f2.close()

0 0
原创粉丝点击