2
[Python] Concatenate JavaScript Files
source link: http://siongui.github.io/2016/02/25/python-concatenate-javascript-files/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[Python] Concatenate JavaScript Files
February 25, 2016
Concatenate JavaScript files via Python script.
#!/usr/bin/env python # -*- coding: utf-8 -*- # import os def concatJS(dirpath): combinedJS = "" for filename in os.listdir(dirpath): if filename.endswith(".js"): filepath = os.path.join(dirpath, filename) print("combining " + filepath + " ...") with open(filepath, "r") as f: combinedJS += f.read() return combinedJS if __name__ == "__main__": print(concatJS("."))
Tested on: Ubuntu Linux 15.10, Python 2.7.10.
References:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK