#22 Exercise - OS Module in Python

Published: 22 January 2023
on channel: Afshan - AFS Hackers Academy
277
10

In this video, we're gonna learn about the python OS module.

Python OS module provides the facility to establish the interaction between the user and the operating system.
It offers many useful OS functions that are used to perform OS-based tasks and get related information about operating system.

Timestamp:
00:00:08 - Overview of OS module

00:00:31 - Using the os module, create a variable called "current_directory" that holds the current working directory.

00:01:48 - Use the os.listdir() method to create a list of all the files in the current working directory and print the list.

00:03:35 - Use the os.mkdir() method to create a new directory called "test_directory".

00:04:38 - Use the os.rmdir() method to delete the "test_directory" that you just created.

00:05:32 - Create a file called "test_file.txt" in the current working directory using the open() function.

00:06:26 - Use the os.rename() method to rename the "test_file.txt" to "renamed_file.txt".

00:07:37 - Use the os.path.isdir() method to check if a directory called "test_directory" exists and print the result.

00:08:45 - Use the os.path.abspath() method to print the absolute path of a file called "renamed_file.txt".

00:09:48 - Use the os.path.isfile() method to check if a file called "renamed_file.txt" exists and print the result.

00:10:52 - Use the os.path.getsize() method to get the size of "renamed_file.txt" and print the result.


On this page of the site you can watch the video online #22 Exercise - OS Module in Python with a duration of hours minute second in good quality, which was uploaded by the user Afshan - AFS Hackers Academy 22 January 2023, share the link with friends and acquaintances, this video has already been watched 277 times on youtube and it was liked by 10 viewers. Enjoy your viewing!