- 论坛徽章:
- 0
|
文件名:change.log
我想匹配到error并返回行.
类似于grep error change.log
用python如何实现?
change.log 文件内容
Please wait while, the wizard is runing now!
if you arrived at this page by clicking a link, check the website address in the address bar to be sure that it is the address you were expecting.
when going to a website with an address such as https://example.com try adding the 'www' to address.
if you choose to ignore this error and continue, do not enter private information into the website.
For more information, see 'Certificate Error' in Internet Explorer Help!
用perl实现如下:
#!/usr/bin/perl -w
open(F1,"change.log" ||die "Cannot open change.log !";
my @grp=<F1>;
foreach my $va(@grp) {
#print $va;
if ($va=~/error/i) {
print "$va\n";
}
}
python怎么匹配? |
|