一段python代码,把某个路径下的代码文件复制到一个文件中,方便编写代码文档。
代码的样式可以自己控制(换行,空行)
import os, sys
path = r'D:\\onion\\code\\java\\'
fns = [os.path.join(root, fn) for root, dirs, files in os.walk(path) for fn in files]
outfile = open('D:\\onion\\code\\code5.txt', 'wb')
for f in fns:
# print(f)
f1 = open(f, "r")
lines = f1.readlines()
for line in lines:
if line.split():
#sys.stdout.write(line)
outfile.write(line)
outfile.close()
print(len(fns))