我一直在搜索,虽然我发现关于如何简单地让 python 让 linux 使用 cat 函数将文件连接到单个文件的冗长而复杂(许多我不需要的功能)。
从我的阅读显然 subprocess 是做到这一点的方法。这是我所拥有的,但显然不起作用:(
subprocess.call("cat", str(myfilelist[0]), str(myfilelist[1]), str(myfilelist[2]), str(myfilelist[3]), ">", "concatinatedfile.txt"])
以上假设:
myfilelist[]
上面的列表有 4 个文件名 + 路径作为列表;例如,列表中的一项是“mypath/myfile1.txt”
我也会采用非子流程(但简单)的方法