Created
February 25, 2019 06:19
-
-
Save lqqyt2423/f6779249c05dd721748eab7c031f81bb to your computer and use it in GitHub Desktop.
合并当前目录下的文件,全部打印出来
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import os | |
root_dir = os.getcwd() | |
names = ["js"] | |
def list_code(dir): | |
for lists in os.listdir(dir): | |
path = os.path.join(dir, lists) | |
if 'node_modules/' in path or 'mock/' in path: | |
continue | |
if os.path.isfile(path) and os.path.splitext(path)[-1][1:] in names: | |
with open(path) as f: | |
print(f.read()) | |
if os.path.isdir(path): | |
list_code(path) | |
list_code(root_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment