37,720
社区成员
发帖
与我相关
我的任务
分享
open(FILE2, $file2) or die;
my %mappings = (do { local $/; <FILE2> } =~ /(PNG, \S+, )(.+)/g);
open(FILE1, $file1) or die;
my $c = do { local $/; <FILE1> };
$c =~ s/(PNG, \S+, )(.+)/$1 . $mappings{$1}/ge;
open(FILE1, '>', $file1) or die;
print FILE1 $c;
import re
mappings = dict(re.findall(r'(PNG, \S+, )(.+)', open(file2).read()))
with open(file1, 'r+') as f:
c = re.sub(r'(PNG, \S+, )(.+)', lambda m: m.group(1) + mappings[m.group(1)], f.read())
f.seek(0)
f.write(c)