The second edition of this best-selling Python book (100,000+ copies sold in print alone) uses Python 3 to teach even the technically uninclined how to write programs that do in minutes what would take hours to do by hand. There is no prior programming experience required and the book is loved by liberal arts majors and geeks alike. Show
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 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 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. Foreword
Notes. Python 3. From No Starch Press, 2015. Creative Commons. More at: boolean, comparison, operator, flow control, condition, conditional, loop global, local, variable, scope Exception handling with data type, index, sublist, subset, slice, change, concatenate, concatenation, tuple, convert, tuple to list loop Dictionaries are not indexed and ordered like lists. Pretty print with the Nested dictionaries and lists. Escape character: Raw strings: Triple
quotes: Comment:
The In addition:
Chapter 7, Pattern Matching and Regular Expressions¶patterns of text, with, without regular expression, regex, object, match, matching, group, grouping, pipe, question mark, star, ?, *, plus, +, curly bracket, {, }, character class, digit, numeric, letter, underscore, space, tab, newline, caret, ^, dollar sign, $, wildcard, dot, ., dotstar, newline, symbols, case-sensitive, case-insensitive
Chapter 8, Reading and Writing Files¶file, file path, filename
Handle absolute and relative paths. Find file sizes and folder contents. Check path validity. Windows: backslash or
Yields: UNIX: forwardslash or
Yields: Read and write files:
Handle binary files.
Pretty printing:
Chapter 9, Organizing Files¶pdf, every sub-folder, folder, foldername, subfolder, filename, file, remove, zero, change titles, compress, decompress, zip, unzip
Copy, move, rename, and delete files and folders.
Delete, empty, remove files and folders, and change the path.
Delete files and folders, but much safer.
Compress and uncompress. Read the content of compressed and zipped files.
Chapter 10, Debugging¶Handle errors with Raise exceptions with a
Discover what and how an error happens and obtain it as a string with the An assertion is a sanity check performed with an
Display log messages as the program runs. Log to a file. Debug a code. Enable and disable logging. Enable an IDLE debugger. Set a Chapter 11, Web Scraping¶html
Open a browser to a specific webpage (in
conjunction with the Use:
Download files and webpages; similar to opening, reading, writing, closing files and folders.
HTML crash course!
Use:
Launches and controls a web browser. Fill and submit forms. Simulate mouse clicks. Find elements on a page. Click on a page. Send special keys. Combining modules :
Chapter 12, Excel Spreadsheets¶
Read Excel documents. Open Excel documents. Get sheets from a workbook. Get cells from the sheets. Convert letters and numbers. Get rows and columns from sheets. Write results to a file. Use:
Chapter 13, PDF and Word Documents¶
Extract text from a PDF. Decrypt a PDF. Create PDF. Copy pages, rotate pages, overlay pages from a PDF. Add a logo, a timestamp, a watermark to a PDF. Use:
Read word documents. Get the full text from a .docs file. Style paragraphs. Create word documents with nondefault styles. Write word documents. Add headings, lines, page breaks, and pictures. Use:
Chapter 14, CSV Files and JSON Data¶
Read, open CSV. Split the file. Print CSV. Loop within a file or through many files. Write CSV. Change delimiters and lineterminators. Remove the header. Use:
Alike web scraping. API. Read, load, write, dump data. Use:
Chapter 15, Time, Scheduling Tasks, and Launching Programs¶
Read the system clock for the current time. Pause a program (sleep). Round numbers. Use:
Compute time and date delta. Retrieve a specific moment. Add a timestamp. Add pauses to a routine. Convert datetime object to strings. Convert strings to datetime objects. Use:
Chapter 16, Sending Email and Text Messages¶http, smtp, mail, imap
Connect to an SMTP server. Log in. Search for emails. Send a message. Encrypt emails. Retrieve and delete emails. Disconnect from the SMTP server.
Connect to an IMAP server. Log in. Search for emails. Fetch an email and mark it as read. Get email addresses from a raw message. Get the body from a raw message. Delete emails. Disconnect from the IMAP server. Use:
Send text messages, SMS. Chapter 17, Manipulating Images¶Color and RGBA crash course!
Manipulate images with Pillow. Work with the image data type. Crop, copy, paste an image. Multiply images tiles. Resize, rotate, flip an image. Change pixels. Draw on images (points, lines, rectangles, ellipses, polygons, text). Use:
Chapter 18, Controlling the Keyboard and Mouse with GUI Automation¶virtual keystrokes, mouse clicks
Shutdown the computer. Log out from a session. Pauses, fail-safes. Control mouse movements and move the mouse. Get the mouse position and control the mouse. Control the keyboard. Send a string from the keyboard. Type in key name. Press and release buttons. Activate hotkey. Use:
Appendix A¶
Appendix B¶
Appendix C¶Answers from questions: chapter 2 to 18. Additional Content¶
|