Python的标准库中的os模块包含普遍的操作系统功能。
os模块负责程序与操作系统的交互,提供了访问操作系统底层的接口
加载
os 常用方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| os.getcwd()
os.listdir('dirname')
os.remove(‘path/filename’)
os.rename(oldname, newname)
os.walk()
os.chdir('dirname')
os.mkdir/makedirs('dirname')
os.rmdir/removedirs('dirname')
os.chmod()
os.path.basename(‘path/filename’)
os.path.dirname(‘path/filename’)
os.path.join(path1[,path2[,...]])
os.path.split('path')
os.path.splitext()
os.path.getatime\ctime\mtime
os.path.getsize()
os.path.exists()
os.path.isabs()
os.path.isdir()
os.path.isfile()
|