您好,欢迎来到步遥情感网。
搜索
您的当前位置:首页详解在Python中移动目录结构的方法

详解在Python中移动目录结构的方法

来源:步遥情感网


这篇文章主要详解在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)	

Copyright © 2019- obuygou.com 版权所有 赣ICP备2024042798号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务