第13题未测试

Posted 我家大宝最可爱

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第13题未测试相关的知识,希望对你有一定的参考价值。

#conding=utf8  
import os,re

base_dir = '../test'
def findAllFile(base):
    for root, ds, fs in os.walk(base):
        for f in fs:
            if re.match(r'.*top0', f):
                fullname = os.path.join(root, f)
                yield fullname

def replace(file_path ,src = 'RTA', target = 'UDF'):
    t = ''
    with open(file_path,'r') as f:
        content = f.read()
        t = content.replace(src, target)
    
    with open(file_path ,"w") as f:
        f.write(t)

for filepath in findAllFile(base_dir):
    print(filepath)
    replace(filepath)

以上是关于第13题未测试的主要内容,如果未能解决你的问题,请参考以下文章