Chapter 18: Automation with Python
File and Directory Automation
import os
# Create a new file
with open("example.txt", "w") as file:
file.write("Hello, Automation!")
# Rename a file
os.rename("example.txt", "new_example.txt")
# Delete a file
os.remove("new_example.txt")# Create a directory
os.mkdir("new_folder")
# List contents of a directory
print(os.listdir("."))
# Remove a directory
os.rmdir("new_folder")Web Scraping
System Monitoring
Automating Emails
Exercises
Best Practices
Last updated