- 快速生成文件夹与文件的脚本
import sys
import os
myfiles = sys.argv[1::]
for f in myfiles:
os.mkdir(f)
os.system(f"touch {f}/{f}.in")
os.system(f"touch {f}/{f}.out")
os.system(f"touch {f}/{f}.cpp")
with open("template.cpp", "r") as fr:
lines = fr.readlines()
for line in lines:
with open(f"{f}/{f}.cpp", "a") as fw:
if line == ' // 1\n':
fw.write(f' freopen("{f}.in", "r", stdin);\n');
elif line == ' // 2\n':
fw.write(f' freopen("{f}.out", "w", stdout);\n');
else:
fw.write(line)