Python Tutorial - Modules #11
OS Docs
Note: I will be using Python 2.7
To start off I would like to explain that I am not fluent in Python but recently saw ѕнα∂σω thread which stated he was going to learn os so I thought to myself that I would to. So what I will be doing is hopefully doing a tutorial every 2-4 days on the OS module, which will both teach me and you.
In this tutorial we will be looking at the basics of the OS module.
First off all we will import the module, to do this we just simply
Code
import osI will now show you how you are able to find out whether a certain directory exists.
Code
import os
path = "c:/users/william/pictures/pic.jpg"
if os.path.exists(path):
print "Dir Exists!"
else:
print "Dir Can Not Be Found!"Just that tiny bit of code could be used in so many ways for example, if that dir exists then you could move it using the shutil module or maybe you would delete that file.
If you got stuck on this tutorial then feel free to contact me.
I will happily listen to any ideas you may have also.
-Cyber Punk
