Automate the Boring Stuff with Python, 2nd Edition

Automate the Boring Stuff with Python, 2nd Edition

Practical Programming for Total Beginners
by Al Sweigart
November 2019, 592 pp.
Covers Python 3.x

Automate the Boring Stuff with Python, 3rd edition coming soon. Click here for details.

Look Inside!

Automate the Boring Stuff with Python, 2nd Edition>Input ValidationWorking with Google SheetsProject: Multiplications QuizAutomate2e

If you’ve ever spent hours renaming files or updating hundreds of spreadsheet cells, you know how tedious tasks like these can be. But what if you could have your computer do them for you?

In this fully revised second edition of the best-selling classic Automate the Boring Stuff with Python, you’ll learn how to use Python to write programs that do in minutes what would take you hours to do by hand—no prior programming experience required. You'll learn the basics of Python and explore Python’s rich library of modules for performing specific tasks, like scraping data off websites, reading PDF and Word documents, and automating clicking and typing tasks.

The second edition of this international fan favorite includes a brand-new chapter on input validation, as well as tutorials on automating Gmail and Google Sheets, plus tips on automatically updating CSV files. You’ll learn how to create programs that effortlessly perform useful feats of automation to:

  • Search for text in a file or across multiple files
  • Create, update, move, and rename files and folders
  • Search the Web and download online content
  • Update and format data in Excel spreadsheets of any size
  • Split, merge, watermark, and encrypt PDFs
  • Send email responses and text notifications
  • Fill out online forms

Step-by-step instructions walk you through each program, and updated practice projects at the end of each chapter challenge you to improve those programs and use your newfound skills to automate similar tasks.

Don't spend your time doing work a well-trained monkey could do. Even if you've never written a line of code, you can make your computer do the grunt work. Learn how in Automate the Boring Stuff with Python, 2nd Edition.

Author Bio 

Al Sweigart is a professional software developer who teaches programming to kids and adults. Sweigart has written several bestselling programming books for beginners, including Automate the Boring Stuff with Python, Invent Your Own Computer Games with Python, Cracking Codes with Python, and Coding with Minecraft (all from No Starch Press).

Table of contents 


Part I: Python Programming Basics
Chapter 1: Python Basics
Chapter 2: Flow Control
Chapter 3: Functions
Chapter 4: Lists
Chapter 5: Dictionaries and Structuring Data
Chapter 6: Manipulating Strings

Part II: Automating Tasks

Chapter 7: Pattern Matching with Regular Expressions
Chapter 8: Input Validation
Chapter 9: Reading and Writing Files
Chapter 10: Organizing Files
Chapter 11: Debugging
Chapter 12: Web Scraping
Chapter 13: Working with Excel Spreadsheets
Chapter 14: Working with Google Sheets
Chapter 15: Working with PDF and Word Documents
Chapter 16: Working with CSV Files and JSON Data
Chapter 17: Keeping Time, Scheduling Tasks, and Launching Programs
Chapter 18: Sending Email and Text Messages
Chapter 19: Manipulating Images
Chapter 20: Controlling the Keyboard and Mouse with GUI Automation

Appendix A: Installing Third-Party Modules
Appendix B: Running Programs
Appendix C: Answers to the Practice Questions

View the detailed Table of Contents
View the Index


“If you are new to Python, get this book. ... If you lie in the category of experienced Pythonistas and haven’t read this book, you should also take out some time and read it.”
The Startup, Medium

"I think many educational resources jump levels way too quickly. One of the best I ever used was Automate the Boring Stuff with Python - that book stayed at the right level the whole way!""
—Oscar Baruffa, @OscarBaruffa

"The best part of programming is the triumph of seeing the machine do something useful. Automate the Boring Stuff with Python frames all of programming as these small triumphs; it makes the boring fun.”
Hilary Mason, Founder of Fast Forward Labs and Data Scientist in Residence at Accel

“I’m having a lot of fun breaking things and then putting them back together, and just remembering the joy of turning a set of instructions into something useful and fun, like I did when I was a kid.”
Wil Wheaton, American actor and writer

“Do you need Automate the Boring Stuff with Python? Yes, if you want to enhance your workflow by using automation, this is an excellent place to start. Highly recommended.”
Network World

“Valuable to have on your extremely useful book.”
Kids, Code, and Computer Science Magazine

“Written in easy to understand language with a gentle approach...Automate the Boring Stuff with Python is the perfect manual to get your computer doing the busywork.”
Games Fiends

"Automate the Boring Stuff with Python is perfect for anyone who has menial tasks they don't want to spend hours doing."

"Whether you prefer working through a book, or learning by watching, or both together, Automate the Boring Stuff will have you productive in Python in no time."
—Serdar Yegulalp, Info World

"If you seriously want to know how much Python helps with automation, my favorite place is the Automate Boring Stuff with Python book, a simply awesome book."
—Javin Paul, Hacker Noon

"One of the best books for learning Python."
Giles McMullen-Klein, FlickThrough Reviews

"With lessons on how to use Python to program Excel spreadsheets, crawl websites, parse PDFs and Word documents, send emails, and other productivity-boosting task automation, it's a stellar resource for office workers, academics, and administrators."

"This is certainly a much more engaging way to learn Python . . . it gets you all excited by the prospect of making cool little programs that will save you time."
—Andrew Lau,

"I've found both the book and Udemy course to be really helpful."
—Mark S, @Awful_Curious

"Best Python book you can buy today."
—Rodrigo Ribeiro, @mcapablanca

Extra Stuff 

Download the files used in the 1st Edition of this book
Additional Online Resources from 1st Edition

Selected by Cyber Defense Magazine as 1 of 100 Best CyberSecurity Books

Read an interview with Al Sweigart on the Import Python blog!

Al Sweigart was interviewed about practical programming on the Test Talks podcast with Joe Colantonio.

Al Sweigart offers tips on Practical Programming for Non-Engineers on

Read Al Sweigart's advice on for teaching kids how to code.

Al Sweigart chronicles 6 time-consuming tasks you can automate with code, on

Listen to an interview with Al Sweigart about Automate the Boring Stuff with Python on the Talk Python to Me podcast!


View the latest errata.