uos – Filesystem functions¶
This module contains miscellaneous operating system functions.
Warning
All filesystem operations accept absolute paths only and will raise a
ValueError when passed an invalid path.
Functions¶
- uos.listdir(path)¶
- Obtain a list of names or the entries in the provided directory. - If the - pathis provided in type- bytes, the filenames returned are also of type- bytes; otherwise they are of type- str.- Note - The list is in an arbitrary order and does not include special entries such as - .and- .., even if they are present in the directory. If a file is removed from or added to the directory during this function call, its appearance or otherwise is undetermined.- Parameters
- path (str or bytes) – Full path to the directory. 
- Returns
- List containing the names of the entries in the directory. 
- Return type
- str or bytes 
 
- uos.mkdir(path, mode=None)¶
- Create a directory. - Parameters
- path (str) – Full path to the new directory. 
- mode (optional) – This parameter is ignored and is only present to ensure compatibility. 
 
- Raises
- FileExistsError – Directory already exists. 
 
- uos.remove(path)¶
- Remove (delete) a file. - Parameters
- path (str) – Full path to the file. 
- Raises
- IsADirectoryError – The provided - pathis a directory rather than a file. Use- rmdir()to remove directories.
- FileNotFoundError – File does not exist. 
 
 
- uos.rmdir(path)¶
- Remove (delete) a directory. - Parameters
- path (str) – Full path to the directory. 
- Raises
- FileNotFoundError – The directory does not exist. 
- OSError – Directory is not empty.