MCS 260 Fall 2020
Emily Dumas
import os
gives your program access to lots of functions that ask the operating system to do things.
Today we focus on the filesystem operations in this module.
pwd
- print working directorycd
- change working directoryls
- list files in a directorycat
- display file contentsrm
- remove a filemkdir
- create a directoryrmdir
- remove a directoryos.getcwd()
- get working directoryos.chdir(dirname)
- change working directoryos.listdir(dirname)
- get list of files in directoryos.mkdir(dirname)
- create a directoryos.rmdir(dirname)
- remove a directoryos.remove(filename)
- remove a fileos.path.join(part0,part1,...)
- join path components (using proper separator for the OS)os.path.exists(name)
- True if name
existsos.path.isfile(name)
- True if name
is a fileos.path.isdir(name)
- True if name
is a directory