Python工具,用于在文件中更改或替换文本字符串。
项目描述
这是一个简单的Python工具,用于在文件中更改或替换文本字符串。对于程序员来说,如果他们想替换/更改多个文件的代码,例如函数、类、变量等,这是一个很好的工具,无论是递归文件还是非递归文件。
安装
从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