用于更改或替换文件中文本字符串的python工具。
changewords的Python项目详细描述
只需python工具来更改或替换文件中的文本字符串。 这个工具对于程序员来说非常好,如果他们想替换/更改许多文件的代码, 例如:递归文件的function、class、variable等。
安装
从pypi安装:
$ pip install changewords
使用量
usage: changewords.py [-h] [-p PATH] [-ft FILE_TYPE] [-fs FROM_STRING] [-ts TO_STRING] Python tool to change or replace the strings in files. optional arguments: -h, --help show this help message and exit -p PATH, --path PATH the starting path or parent path name by default is current path/folder. -ft FILE_TYPE, --file_type FILE_TYPE file type you are looking for, eg: '.py', '.txt' by default is '.py' (python files) -fs FROM_STRING, --from_string FROM_STRING the string to change/replace -ts TO_STRING, --to_string TO_STRING the string replacement
示例
$ changewords -p=changewords_test -ft=.py -fs=helloworld -ts=mantabjiwa # or $ changewords --path=changewords_test --file_type=.py --from_string=helloworld --to_string=mantabjiwa
运行测试
要运行测试,请使用:
$ python tests.py