去除行号(Python3)
来源:互联网 发布:java反射机制的优缺点 编辑:程序博客网 时间:2024/05/21 13:58
主要利用正则表达式来去除行号
import re# 输出文件的文件名output = open('data.txt', 'w')# 输入文件的文件名file_object = open('in.txt')try: line_str = file_object.readline() while line_str: line_str = file_object.readline() p = re.findall(r'[0-9]{1,4}:',line_str) if len(p)!=0: # print (p[0]) output.write(line_str.replace(p[0],''))finally: file_object.close( ) output.close()
效果:
处理前
1: import java.io.BufferedReader;
2: import java.io.FileInputStream;
3: import java.io.IOException;
4: import java.io.InputStreamReader;
5:
6: /**
7: *
8: * @author
9: *
10: *
11: */
处理后
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author
*
*
*/
0 0
- 去除行号(Python3)
- 复制代码去除行号
- 复制代码去除行号
- 去除代码行号
- 如何去除文件中的行号
- 使用UltraEdit去除前导行号
- 工具:去除文件的行号
- 去除复制代码的行号
- history命令结果去除行号
- 去除网页中代码的行号
- 去除网页中代码的行号
- 代码中去除行号的方法
- 去除网页中代码的行号
- 正则表达式去除代码的行号
- 正则表达式去除粘贴代码行号
- Notepad++搜索结果带行号如何去除
- python3去除str中的n、r
- 让DataGridView显示行号,去除空记录行
- c++ primer 学习(四) 函数
- C#控制台基础 结构,类在声明的同时初始化
- 关于JavaScript substr() 方法
- int与string类型转换
- Oracle10g忘记system,sys密码的解决办法。
- 去除行号(Python3)
- MySQL中实现分割字符串的方法
- 更换启动图片
- sourcetree 无法提交代码
- Retrofit2.0 和Instant Run 冲突导致 java.lang.ArrayIndexOutOfBoundsException
- C语言学习3
- tolua++ lib 和 exe的生成
- String类型出生年月计算年龄
- leetcode Maximum Depth of Binary Tree