修改类名

1.创建文件 .txt。 copy下面代码,修改文件.py(ChatRoom 修改成Common)
2.放在.xcodeproj 统一目录
3.cd 到外一层级,

  1. 执行 python app.py
#!/usr/bin/env python
import os
for dirpath, _, filenames in os.walk('.'):
    for filename in filenames:
        if filename.startswith('ChatRoom'):
            oldFile = os.path.join(dirpath, filename)
            newFile = os.path.join(dirpath, filename.replace('ChatRoom', 'Common', 2))
            print(newFile)
            inFile = open(oldFile)
            outFile = open(newFile, 'w')
            replacements = {'ChatRoom':'Common'}
            for line in inFile:
                for src, target in replacements.items():
                    line = line.replace(src, target)
                outFile.write(line)
            inFile.close()
            outFile.close()
            os.remove(oldFile)


你可能感兴趣的:(修改类名)