2013-02-18 22:09:42 +08:00
|
|
|
#!/usr/bin/python
|
|
|
|
# replaces.py
|
|
|
|
# Copyright (c) 2012 cocos2d-x.org
|
|
|
|
# Author: WangZhe
|
|
|
|
|
|
|
|
def replaceString(filepath, src_string, dst_string):
|
|
|
|
content = ""
|
2013-02-20 13:26:41 +08:00
|
|
|
f1 = open(filepath, "rb")
|
2013-02-18 22:09:42 +08:00
|
|
|
for line in f1:
|
|
|
|
if src_string in line:
|
|
|
|
content += line.replace(src_string, dst_string)
|
|
|
|
else:
|
|
|
|
content += line
|
|
|
|
f1.close()
|
2013-02-20 13:26:41 +08:00
|
|
|
f2 = open(filepath, "wb")
|
2013-02-18 22:09:42 +08:00
|
|
|
f2.write(content)
|
|
|
|
f2.close()
|
|
|
|
# end of replaceString(filepath, src, dst) function
|
|
|
|
|