From the course: Intermediate Python for Non-Programmers
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Creating a file - Python Tutorial
From the course: Intermediate Python for Non-Programmers
Creating a file
- [Instructor] For the last three videos of this section we're going to be talking about how to work with files in Python. How to create them, read them, and edit them. And to me, this skill is so cool and important for you because it really allows you to start doing some automation on your own computer to create some Python scripts that are really personalized to you. So with that, let's talk about how to create a file in Python. We're going to call a function called open. And inside of open we need to pass two parameters. The first one is the name of the file that you'd like to create. So in our case, I'm just going to call this cheese dot txt. I think this is just sort of a fun name here. And then we do a comma, pass in that second parameter, which is how do you want to work with this file? And there's three different options when you're creating a file. There's x, w, and a, we're going to go through each of these but we'll start with X. And x is just meaning that we're going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.