我得到了一个脚本,我想用它来更改整个项目文件夹结构中的重复字符串。一旦改变了,我就可以把它签入SVN。不过,当我运行脚本时,它会进入.svn文件夹,我希望它进入该文件夹。我怎样才能做到这一点?下面的代码,谢谢。
import os
import sys
replacement = "newString"
toReplace = "oldString"
rootdir = "pathToProject"
for root, subFolders, files in os.walk(rootdir):
print subFolders
if not ".svn" in subFolders:
for file in files:
fileParts = file.split('.')
if len(fileParts) > 1:
if not fileParts[len(fileParts)-1] in ["dll", "suo"]:
fpath = os.path.join(root, file)
with open(fpath) as f:
s = f.read()
s = s.replace(toReplace, replacement)
with open(fpath, "w") as f:
f.write(s)
print "DONE"
试试这个:
然后继续处理。
Err... what?
相关问题 更多 >
编程相关推荐