How to Create a Nested Directory in Python?
Learn how to create a nested drirectory in Python.
Learn how to create a nested drirectory in Python.
Windows: How to Make Beep in Python To make a beep sound in Python on your Windows machine: Import the library using: import winsound Call windsound.Beep(frequency, duration) for your desired frequency (in Hertz) and duration (in milliseconds). For example, winsound.Beep(2000, 1500) would make a sound with 2000 Hz for 1.5 seconds. Here’s the relevant code … Read more
Working in Python with files and directories in an efficient way is important especially when we are talking about several thousand files. For example, if the goal is to “just” count the number of files in a directory it is probably a good idea to work directly with iterables without creating lists that would take … Read more
Windows PowerShell uses variables to store values, and we have a large set of operators we can use to modify or compare those variables. PowerShell Assignment Operators Assignment Operators allow us to simply create variables and populate them with values in one command: When we call those variables, we can see the values they contain: … Read more
PowerShell foreach Loop Syntax: The keyword ‘foreach‘ is used in Windows PowerShell to iterate through a series or list of items, usually with the intent of performing operations using each item. Example: In the following example, we use PowerShell to read the contents of a text file (C:\Temp\ServerList.txt) filled with server names, storing the values … Read more
[toc] There are various modules that can be easily used to delete a file or folder in Python. In this article, we are going to look at the various methods used to delete a file or folder in Python. Method 1: The os module A Quick Recap to the OS Module:The OS module is a … Read more
File handling can be a tricky area to deal with while you are scripting in Python. There are numerous occasions wherein we need to work with files and folders from within the Python script. Thus, Python facilitates us with numerous file operations that makes life easier for us when we come across such situations. One … Read more
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
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
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
I love tweaking my coding workflow. Small improvements accumulate over time and can lead to a massive productivity increase. Today, I caught myself being annoyed that I always needed to spend three clicks or so just to open a Python file in IDLE, the default Python editor on Windows. Time to change that! Do you … Read more
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