Saturday, May 25, 2013

Python tutorial Part 2 time and making folders

The python time module is very useful for finding current time. Below you will find a few examples of the module in use and how to extract year, month, day, hour, minute, second, and microsecond.


















To find elapsed time used the the code below.













To make a folder with the current date import sys, os, and datetime.  Use strftime to get the Year with century as a decimal number, get the month as a decimal number, and the day of the month as a decimal number.  Then test to see if the folder already exists and if not make the folder.  Below you will see the folder which was made by the script to the right of it.