os.getcwd()
- 獲得當前工做目錄,即當前Python腳本工做的目錄路徑
os.listdir()
os.remove()
os.removedirs(r「c:\python」)
os.path.isfile()
os.path.isdir()
os.path.isabs()
os.path.exists()
os.path.split()
e.g
os.path.split('/home/swaroop/byte/code/poem.txt')
('/home/swaroop/byte/code', 'poem.txt')
os.path.splitext()
e.g
os.path.splitext('/usr/local/test.py')
('/usr/local/test', '.py')
os.path.dirname()
os.path.dirname()
os.path.basename()
os.path.basename()
os.getenv("HOME")
os.environ
os.environ.setdefault('HOME','/home/alex')
os.linesep
- 給出當前平臺使用的行終止符
Windows使用'\r\n',Linux and MAC使用'\n'
os.name
- 指示你正在使用的平臺
對於Windows,它是'nt',而對於Linux/Unix用戶,它是'posix'
os.rename(old,new)
os.makedirs(r「c:\python\test」)
os.mkdir(「test」)
os.stat(file)
os.chmod(file)
os.path.getsize(filename)
os.path.join(dir,filename)
os.chdir(dirname)
os.get_terminal_size()
os.kill(10884,signal.SIGKILL)