python2.7:创建修改删除目录

来源:互联网 发布:喜马拉雅fm无网络连接 编辑:程序博客网 时间:2024/06/05 12:00
#coding=utf-8import osprint os.getcwd() #get current work diros.chdir("C:\Users\Administrator\Desktop\Pyhton2.7Tests") #change dirprint os.getcwd()print os.listdir(os.getcwd()) #filename list dir,return tupleos.mkdir(os.getcwd() + "\\file") #make diros.rmdir(os.getcwd() + "\\file") #remove dir#注意:删除目录需要说明的是,使用os.rmdir删除的目录必须为空目录,否则函数出错。# 输出:# D:\Program Files (x86)\Notepad++# C:\Users\Administrator\Desktop\Pyhton2.7Tests# ['chardet_test.py', 'chardet_test.txt', 'float2int.py', 'open_file_test.py', 'op# en_file_test.txt', 'os_test.py', 'type_isinstance_test.py', 'unicode_str_test.py# ']# 请按任意键继续. . .

0 0
原创粉丝点击