用java或python解答下面的问题?
发布网友
发布时间:2022-04-18 08:52
我来回答
共2个回答
热心网友
时间:2022-04-18 10:22
Python实现代码如下:
Python代码
import re
filename = 'logs_text.txt'
with open(filename) as data:
text = data.read()
pattern = r"_conf={ '(.+?)' }"
eligible = re.findall(pattern, text)
result = [_ for _ in eligible if int(_) > 5000]
print(result)
热心网友
时间:2022-04-18 11:40
package test;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class I {
public static void main(String[] args) throws IOException{
FileReader read=new FileReader("ogs_text.txt");
BufferedReader bf=new BufferedReader(read);
String s=bf.readLine();
while (s!=null) {
try {
int i=s.indexOf("_conf={ 'xxxxx' }");
String s1="";
if (i==0) {
s1=s.substring(0, i);
}else {
s1=s.substring(i-1, i);
}
int i1=Integer.getInteger(s1);
if (i1>5000) {
System.out.println(s=bf.readLine());
}
s=bf.readLine();
} catch (Exception e) {
// TODO: handle exception
s=bf.readLine();
}
}
bf.close();
read.close();
}
}
以上为Java语言