中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Python搜索文件代碼

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用
這里以在windows下搜索并啟動QQ為例,我先把開始菜單、桌面和快速啟動欄找了一遍,這樣能縮短查找時(shí)間。如果找不到再到每個分區(qū)中查找。 
    import os  
    disk=['D','E','F','G','H']  
    def search_file(filename,search_path,pathsep=os.pathsep):  
        for path in search_path.split(pathsep):  
            candidate = os.path.join(path,filename)  
            if os.path.isfile(candidate):  
                return os.path.abspath(candidate)  
    if __name__=='__main__':  
        found=False  
        for i in os.walk('C:\ProgramData\Microsoft\Windows\Start Menu\Programs'):  
            search_path=i[0]  
            find_file=search_file('騰訊QQ.lnk',search_path)  
            if find_file:  
                os.startfile(find_file)  
                found=True  
        if not found:  
            for i in os.walk('C:\Users\Jack\Desktop'):  
                search_path=i[0]  
                find_file=search_file('QQ.exe.lnk',search_path)  
                if find_file:  
                    os.startfile(find_file)  
                    found=True  
        if not found:  
            for i in os.walk('C:\Users\Jack\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch'):  
                search_path=i[0]  
                find_file=search_file('騰訊QQ.lnk',search_path)  
                if find_file:  
                    os.startfile(find_file)  
                    found=True  
        if not found:  
            for i in range(0,5):  
                for j in os.walk(disk[i]+':/'):  
                    search_path=j[0]  
                    find_file=search_file('QQProtect.exe',search_path)  
                    if find_file:  
                        os.startfile(find_file)  
                        found=True  
        if not found:  
            for i in os.walk('C:/Program Files/QQ'):  
                search_path=i[0]  
                find_file=search_file('QQProtect.exe',search_path)  
                if find_file:  
                    os.startfile(find_file)  
                    found=True  
        if not found:  
            print"無法找到QQ"  

標(biāo)簽: 搜索

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇: JavaScript計(jì)算2個日期之間相差天數(shù)

下一篇: Andriod實(shí)現(xiàn)刮刮卡的效果