How Do I List All Files of a Directory in Python?

Problem: Given a directory. How to list all the files in the directory using Python? Video Solution  What is a directory?A directory is a unit organizational structure used to store a collection of programs and subdirectories. Sometimes as a coder you have to deal with the countless number files within different directories. Hence, it becomes … Read more

What’s the Difference Between ‘py’ and ‘python’ in the Terminal?

Problem If you run Python in your terminal or shell, you may have realized that there are two ways to do so: using the “python” command and using the “py” command. What’s the difference? Example Say, you want to check your Python version. You can run both commands and the output is different! Here’s using … Read more

How to Get a Windows Screenshot in Python?

Problem Formulation Say, you run a Python program on your Windows machine and you want it to take a screenshot. How to accomplish this programmatically? Method 1: Multiple Screen Shots Module To programmatically record one or more screenshots in your Python program, run the sct.shot() function from the mss module. Install the Multiple Screen Shots … Read more

How to Open Outlook in Python?

Problem Formulation Given a Windows operating system on which you have the Microsoft Outlook email program installed. How to open Microsoft Outlook using only a function call in your Python script? Solution: os.startfile(‘outlook’) The easiest way to open Outlook on Windows using only a short and concise Python One-Liner is to use the os.startfile(‘outlook’) function … Read more