遍利所有文件并写入一个文本文件,各文件结尾用等号隔开?解决办法

遍利所有文件并写入一个文本文件,各文件结尾用等号隔开?
大家好,小弟初学,遇到个棘手问题,望高手指点,最好能给个完整的程序,让小弟学习学习。。。谢谢。。。

现有180个文本文件,希望将其全部写入一个文本文件,每个文件后加个=(等号)隔开, 

例如,

file1.txt
lalalal

file2.txt
dedede

file3.txt
mememe


目标文件

lalalal
=
dedede
=
mememe

------解决方案--------------------
我自己写了点,先在我自己的目录下生成了180个文件,里面写了些内容,然后再读出来,放到另外一个文件夹下面去的

Python code

import os
import time

basepath = r'D:\Program Files\workspace\OnlyForTest\src\runEnvironment\floder'
for i in range(181):
    path = os.path.join(basepath, 'file_' + str(i) + '.txt')
    with open(path, 'w') as f:
        f.write(time.ctime() + '\n')
        f.write('filename:' + 'file_' + str(i))



destpath = r'D:\Program Files\workspace\OnlyForTest\src\runEnvironment\dest\dest.txt'
with open(destpath, 'w') as f:
    filelist = os.listdir(basepath)
    for filename in filelist:
        path = os.path.join(basepath, filename)
        with open(path, 'r') as ff:
            for var in ff:
                f.write(var)
            
            f.write('\n==========================\n')

------解决方案--------------------
Perl code
#!/usr/bin/env perl
#

use strict;
use warnings;

my $target = 'all.txt';
open my $OUT, '>', $target or die $!;
for my $file (<*.txt>) {
    next if $file eq $target;
    print "$file\n";
    open my $FD, $file or die $!;
    for my $line (<$FD>) {
        print $OUT $line;
    }
    print $OUT '=' x 80, "\n";
    close $FD;
}
close $OUT;

------解决方案--------------------
Perl code
use strict;
use warnings;
use IO::File;

@ARGV = qw( res.txt t1.txt t2.txt t3.txt );
my $rfile = new IO::File(shift, 'w');
$/ = undef;
print {$rfile} "$_=\n" while(<>);

------解决方案--------------------
Python code
import fileinput
import glob
import os

''' 指定目录下的*.txt内容写入target '''

stream = fileinput.FileInput(
    glob.glob(os.path.join(datapath, '*.txt'))
    )

lastprocess = ''
with open(target, 'wt') as handle:
    for ln in stream:
        if stream.isfirstline():
            if lastprocess:
                handle.write('=\n')
            else:
                lastprocess = stream.filename()
        handle.write(ln)