From the course: Python Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Opening, reading, and writing

Opening, reading, and writing - Python Tutorial

From the course: Python Essential Training

Opening, reading, and writing

- Watching output being printed to the screen is all well and great, but often as programmers we're asked to produce something real, you know, something tangible, usually for those management types that want to see a physical file they can attach to email or open in Excel or whatever it is they do with files. Sometimes they give you files and they want your program to read them. Fine, we'll use their dang files. Let's go to the code. The first thing you need to know about working with files in Python is that it's not quite as simple as when you double-click an icon on your desktop. We're working a little more directly with the operating system and so there are some things that you need to manage. And one of those things is whether we're simply reading the contents of the file or whether we intend to make changes to it, writing it. And this is because it causes problems if two applications are making changes to the same…

Contents