All right, now it is time for that button, find your input output.
And how to handle it.
OK, so you want to read fine to open fire for writing to open fire already existed for writing or.
Append to a specific file we would use, and actually this is supported in the but you'd know how to
do that.
Actually, it is like this.
So first declare a variable name, I would name it in my case, F, which is the first file I will use
the open function.
This is to open a file description.
Then it has the following.
So it has the first parameter.
The second parameter.
The first parameter is the name of the file.
OK, so I will name it whatever I want.
And you can choose this file to be either read, write, read, tried to up into it if it is already
existed or not.
Now actually that depends on the mode, which is the second parameter here.
But in my case I'm using that read mode, which is I want to read a file that already existed.
So I would return here.
And by the way, you can see that the amended by here it is here inside the Python files, if you remember
what we did previously.
So you can see that now I will create a text file here and I will name this to the text, OK?
And I will put here, as you can see, some values inside it.
Yeah.
By the way, I'm using the equal command and the touch command to create the text file and to add this
specific value, which is the same values inside it.
Actually, it's up to you.
You can use whatever you want.
No big deal.
So actually, let's open this file and I'm using them, by the way, here.
So let's put like two arbitrary values line whatever.
And here is in occupied, for example, or end of the line.
OK, last line, for example.
OK, and let's save it.
By the way, if you don't like them, I recommend you to learn it to know how to use it for actually
it's very Boltwood Ed.
Yeah I know it is old fashioned Izzet say but actually for you as a high Batista cybersecurity engineer,
it's important actually and very recommended.
I recommend you a lot to learn about it and its shortcut.
It's powerful.
Use it anyway.
Just use any tuxedoed for now, if you are not familiar with them and what arbitrary value inside that
is the text file that that already here inside the same level of the amended by that we are writing
and now its name.
So just the text file and open it for it.
OK.
All right.
Now I want to print the content of this file.
I will use that lead function.
So F which is the name of the variable that we thought this thing and I would use it.
OK, so this will read the whole content of this text file, but it will not be printed because the
output will be here.
So I will use the print function for that and then I will I will print the read like this.
So actually if I go there and read and see if it is will show us what we need.
So if I type that by three men, yeah.
You can see it is as expected, the same values line to blah blah blah until we reach the end of line
last night.
OK.
So as you can see, we opened this file, Fareed, as you can see, the note is read and that is the
text file is there and existed.
But what if we want this to actually and try to read this and actually read to the text is not here.
So as you can see, no such file or directory.
Now, I actually don't worry about this.
We will handle it in the next picture immediately.
How to handle the errors in the file.
And you know, it is not something big deal.
It is the same way as what we learned previously from the error handling.
And you can see that we will start using specific file errors or specific errors inside the accept.
OK, anyway, until that time, it's not OK.
For now, let's open a fight for writing.
So this tool.
But this time the more I will use it for.
Right.
Which means I want to write inside.
OK.
And this time I will add this content so it can content equal.
And this is the content.
I want this new content to be overwrite, overwritten onto this text to file.
But actually it had it is empty and it is not existed.
So yeah, this is the only data it will be.
So some content, OK.
And for that I would use this time I will use that of the right function.
OK, so the right function here, it would write to this f that we open it for writing and what we would
write, we would write the content, the content variable, as you can see, content like this.
And here this is the variable.
And finally, after it is, everything is correct.
We want to print and read what inside this this to it should because some content right now.
Let's check it out actually.
Yeah, you can see the fine is not readable.
Yeah, you may ask me, but what happened when maybe you forget something actually.
Well this f the three.
Yeah, we open it as what.
As Right.
So how to read something open as I write.
This is not right.
Right.
So how to do thinking about it when actually we will use the closed function.
So F.
The clothes function, so this will close the final description that we open it as right, then we can
create a new variable and use the open function and name it just to the text.
And this time we would open it as read, not as a write.
And then we can read this out and it should be working.
All right, let's check this out.
So the screen, the screen first and you can see it is working as expected and which is some content.
OK, so far, so good.
All right, Andrea, regarding the models actually and the functions for that, I hope you can just
open your browser and type Biton or models.
And from there you can see there are a lot of.
And from there, you can see there are a lot of websites differences, but actually I recommend you
to go to the official documentation because there you can see that there are a lot of exemptions and
functions you can use.
So, yeah, I need to go to the I want to start with you here.
Yeah.
Here you can see that we can add.
This is the open the encoding, so you can see that we have mode's this time and don't worry, I will
show you the mods right away.
Just quickly.
I mean, so here you can see that we have a lot of functions actually.
So you can see that the flash closed is setit readable with line with lines.
Seage tell.
Actually a lot of functions can be used and useful can be depends on the situation you want.
So actually if I go to this website.
I just want to show you something here.
The mods, actually, you can see these are the mods that are available on Biton.
So, yeah, you can see that we have read we have read Binary or A, B or B, so this is to read in
binary format only we have X hour plus, which means read, as you can see, five for both read and
write.
OK, so not just for reading it, you can be for reading and writing and you can see that the bones
are placed at the beginning of the far right we have right.
We have our B plus which is read binary.
We have right.
Right.
Binary plus.
And as you can see here, the plus is for read and write, but this time over time overwrite the existing
file.
If it exists, if it does not exist, it will create a new file.
OK, and the same for the B plus there is binary plus for event and this is something new and we have
a B appended for the binary and we have a benefit for both reading and binary in a binary format because
this is a B plus by the way, and the pointer will be at the end of the file if it exists.
OK.
All right.
Have a look there.
Try this out if you are interested.
Now in the next picture, we will talk about the error handling for the python finds out when we open
a fight.
That's why it is not existed, how to handle such errors in a very smooth way.
All right.
Thanks for watching.