在Python中移動(dòng)目錄結(jié)構(gòu)的方法
來源:http://stackoverflow.com/questions/3806562/ways-to-move-up-and-down-the-dir-structure-in-python
#Moving up/down dir structure
print os.listdir('.') # current level
print os.listdir('..') # one level up
print os.listdir('../..') # two levels up
# more complex example:
# This will walk the file system beginning in the directory the script is run from. It
# deletes the empty directories at each level
for root, dirs, files in os.walk(os.getcwd()):
for name in dirs:
try:
os.rmdir(os.path.join(root, name))
except WindowsError:
print 'Skipping', os.path.join(root, name)
This will walk the file system beginning in the directory the script is run from. It deletes the empty directories at each level.
相關(guān)文章
numpy給array增加維度np.newaxis的實(shí)例
今天小編就為大家分享一篇numpy給array增加維度np.newaxis的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-11-11
python3 字符串/列表/元組(str/list/tuple)相互轉(zhuǎn)換方法及join()函數(shù)的使用
這篇文章主要介紹了python3 字符串/列表/元組(str/list/tuple)相互轉(zhuǎn)換方法及join()函數(shù)的使用 ,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-04-04
python查看自己安裝的所有庫(kù)并導(dǎo)出的命令
這篇文章主要介紹了python查看自己安裝的所有庫(kù)并導(dǎo)出,主要包括查看安裝的庫(kù)通過命令查詢,導(dǎo)出庫(kù)安裝文件執(zhí)行命令,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06
python中的socket實(shí)現(xiàn)ftp客戶端和服務(wù)器收發(fā)文件及md5加密文件
這篇文章主要介紹了python中的socket實(shí)現(xiàn)ftp客戶端和服務(wù)器收發(fā)文件及md5加密文件的相關(guān)知識(shí),本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04

