python 查询文件存放地址

import os, time
import sys
import re

def search(path,name):

    for root, dirs, files in os.walk(path):  
        if name in dirs or name in files:
            flag = 1     
            root = str(root)
            dirs = str(dirs)
            return os.path.join(root)
    return -1

#find vcvarsall.bat save address
vcvarsall_path = 'C:\\'
vcvarsall_name = "vcvarsall.bat"  
vcvarsall_answer = search(vcvarsall_path,vcvarsall_name)

#find msvc9compiler.py save address
msvc9compiler_path = 'C:\\'
msvc9compiler_name = "msvc9compiler.py"  
msvc9compiler_answer = search(msvc9compiler_path,msvc9compiler_name)

  

posted @ 2018-07-03 13:18  Anita_harbour  阅读(816)  评论(0编辑  收藏  举报