Join Joe Marini for an in-depth discussion in this video Reading and writing files, part of Learning Python.
Python provides built in methods for working with file types.…You can open files, write data into them, add data onto the end, read the data back…in and so on. Basically, all the things you expect to do…with file objects and that's what we're going to take a look at here in the next chapter.…So, in my example snippets I've scrolled down to the file section, and in chapter 4…lets' begin by opening up the files_start.py file, alright.…So over here in snippets, let's go ahead and copy in these lines right here, and…you don't need to do any imports here. The file type is just built into python,…so I don't need to import any classes just to be able to write files.…
So this line right here line 7, creates a variable named F.…And I'm calling the function open to open a file named textfile.txt.…So open takes 2 arguments, the file I want to open, and then a string…representing the kinds of permissions or operations I want to do on the file.…So in this case I'm passing in the letter w which means write and the plus sign…
- Installing Python
- Choosing an editor/IDE
- Working with variables and expressions
- Writing loops
- Using the date, time, and datetime classes
- Reading and writing files
- Fetching Internet data
- Parsing and processing HTML
Skill Level Beginner
1. Preparing the Development Environment
2. Python Basics
3. Working with Dates and Times
4. Working with Files
5. Working with Web Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.