python正则表达式
来源:互联网 发布:mac连不上校园网 编辑:程序博客网 时间:2024/05/21 21:44
import osimport restext=[]def gettext():with open('a.txt','r+') as fileone:for line in fileone.readlines():line = line.strip()if not line:continuepattern = re.compile(r'"Rplace[^"]+')#同findtext = re.findall(r'"Rplace[^"]+',line)findtext = re.findall(pattern,line)with open('b.txt','a+') as fileone:fileone.writelines(line+'"\n' for line in findtext)if __name__ == '__main__':gettext()os.system('pause')import osimport restext=[]def gettext():with open('a.txt','r+') as fileone:temp =fileone.read()pattern = re.compile(r'"Rplace[^"]+') #同findtext = re.findall(r'"Rplace[^"]+',temp)findtext = re.findall(pattern,temp) with open('b.txt','a+') as fileone:fileone.writelines(line+'"\n' for line in findtext) if __name__ == '__main__':gettext()
阅读全文
0 0
- python正则表达式学习
- c++正则表达式,python
- Python正则表达式(一)
- python的正则表达式
- Python正则表达式
- Python初学-正则表达式
- 正则表达式与python
- python正则表达式学习
- python正则表达式学习
- python正则表达式学习
- python正则表达式
- Python - 正则表达式
- Python正则表达式
- python正则表达式
- Python正则表达式指南
- Python正则表达式指南
- Python 正则表达式指南
- python 正则表达式
- 数据科学课程笔记4 --- 数据工程与技术
- Oracle自带 SQL developer 导入*.csv和*.xls格式的文件
- Vue初体验(九)计算属性
- 魔力手环(网易2017春招笔试题)
- 数组与集合的应用之数组排序与查询(使用选择排序法)
- python正则表达式
- java入门及电脑硬件软件基础(一)
- 仿QQ好友列表 ExpandableListView
- 数组与集合的应用之数组排序与查询(使用冒泡排序法)
- python3实现冒泡排序和插入排序
- Linux sed命令(一)基础
- Modbus-RTU通信入门
- python学习日记(5)
- 安卓控件4