Python Tutorial: File Objects - Reading and Writing to Files

Python Tutorial: File Objects - Reading and Writing to Files

Corey Schafer

8 лет назад

1,772,853 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Yuuji
Yuuji - 07.09.2023 07:54

so if i'm understanding this right when you did (with open('filename') as f: f is the file object which contains the contents of the file?

Ответить
Renato Correia
Renato Correia - 23.07.2023 18:11

thankyou so much

Ответить
Fab Delap
Fab Delap - 13.07.2023 09:27

Which editor do you use ?

Ответить
TronCM
TronCM - 28.06.2023 10:15

what is the IDE of this? its very clean

Ответить
spidey424
spidey424 - 19.06.2023 08:00

Is there a reason f is used? Is there any reason a different variable could be used?

Ответить
Ishan Sinha IIT Mandi
Ishan Sinha IIT Mandi - 17.06.2023 17:34

what does same directory as python file mean ?

Ответить
Jared Brooks
Jared Brooks - 30.04.2023 03:38

Jesus loves you. Start a relationship with Him today before its too late.

Ответить
Brian Ligat
Brian Ligat - 24.04.2023 18:47

Another great tutorial, and now you have 2 puppies !!

Ответить
lordpomind
lordpomind - 23.04.2023 20:41

Now u can just do json.load(f) or json.dump(file, f)

Ответить
VPD
VPD - 18.04.2023 20:56

Great tutorial!

Ответить
DNGRTEGaijin
DNGRTEGaijin - 08.04.2023 08:01

What text editor is this? Sublime? If so, how are you getting output in the terminal at the bottom? when i give it input, it doesnt work?

Ответить
Kostiantyn Karzhanov
Kostiantyn Karzhanov - 14.03.2023 00:05

Thank you Corey! Very cool lesson! Clear and useful 💛

Ответить
Gregory Allen
Gregory Allen - 09.03.2023 23:36

Corey, Your tutorials are extremely helpful. How would I write a SQL created tuple to excel resulting with each variable residing in its own column?

Ответить
Bobby
Bobby - 02.03.2023 10:11

my man 👍

Ответить
Lars Ulrich VEVO
Lars Ulrich VEVO - 20.02.2023 17:00

Cool stuff this is

Ответить
Gabriel Solis
Gabriel Solis - 15.02.2023 21:43

What IDE is that?

Ответить
r7918
r7918 - 09.02.2023 17:56

Does this method, also works for writing any file formats like: .exe and .dll?

Ответить
Camila
Camila - 25.01.2023 01:47

If i have folder have 60 file txt and i want to open it and clean the data how i can do that

Ответить
HanxonCrib
HanxonCrib - 05.01.2023 15:58

Beautiful.

Ответить
Ssenyange Raymod
Ssenyange Raymod - 17.12.2022 10:07

This video is not good for a beginner

Ответить
Shiva smart
Shiva smart - 13.12.2022 13:43

tq

Ответить
Slots - Portugal
Slots - Portugal - 03.12.2022 21:50

Apparently not:
I found this.

FileName = ("...path.../data.txt")
data=file(FileName).readlines()
data.sort()
for i in range(len(data)):
print data[i]

No "open" no "with" no nothing...
Explain if you can.

Ответить
Krish Patel
Krish Patel - 23.11.2022 01:27

well i have one txt input file and from that i want to create multiple output files as different .txt files for each line in input file. do anyone have code for that ?

Ответить
OldRocker
OldRocker - 18.11.2022 18:24

Thank you Corey. That was very clear.

Ответить
Juan E Rojas Rodriguez
Juan E Rojas Rodriguez - 06.11.2022 18:00

This is a great example, but in order to learn a little diverse situation, Do you have an example of the same concept, instead of using a txt file, using a PDF file?

Ответить
yebeteseb Chewata
yebeteseb Chewata - 29.10.2022 08:28

What if I want to read specific IP host from text file

Ответить
raven verburgh
raven verburgh - 21.10.2022 20:49

i am trying to outfile.write key-value's as a user's safe number and password in this notation: 12;8492hf38dhs. After trial and error i found out it's not possible to outfile.write dict's. how do i solve this? should i write a for loop? thanks in advance

Ответить
Vikranth Racherla
Vikranth Racherla - 12.10.2022 04:11

and your soo good

Ответить
Nicholi
Nicholi - 11.10.2022 19:51

My professor showed me the other way where I had to close that. I like the other way with the context stuff.

Ответить
Khaled Alamrani
Khaled Alamrani - 10.10.2022 08:28

Brilliant

Ответить
Tobias Degli
Tobias Degli - 01.10.2022 18:35

Thanks for helping

Ответить
c7hu1hu
c7hu1hu - 20.09.2022 01:55

Uyingelosi

Ответить
trenholme lodge
trenholme lodge - 17.09.2022 21:23

Please. black on white. If there is a setting I can change so the video is black on white, let me know.

Ответить
Boris Sodji
Boris Sodji - 16.09.2022 01:56

I rarely comment a video, but thank you Corey. You earn yourself a subscriber for life 😊.

Ответить
TOP 5-10
TOP 5-10 - 31.08.2022 11:31

It actually writes on the existing file , you just forgot to change r with w on 16 minute

Ответить
Ninotechke
Ninotechke - 31.08.2022 09:11

Thank you Corey

Ответить
finix 741
finix 741 - 30.08.2022 23:11

I'm learning so much from you tutorials without getting frustrated ,thank you so much !

Ответить
Bhavani kurupudi
Bhavani kurupudi - 05.08.2022 06:16

Best python tutorials
The way you are explained is just awesome..

Ответить
Garden of Akira
Garden of Akira - 28.07.2022 07:00

Thank you for the video. I am grateful for your time and contribution. It was very useful and well put. Kind regards, Akira.

Ответить
Nature Nerds
Nature Nerds - 23.07.2022 11:24

How can I create a conditional based on the number of files inside a specifyd folder?

Ответить
Y 7654321
Y 7654321 - 21.07.2022 05:13

Very helpful

Ответить
Ammar Ahmad
Ammar Ahmad - 09.07.2022 12:23

Very clean and too the point tutorial. Thanks for this easy to grab explanation. I'm quite comfortable now as far as basic file operations are concerned.

Ответить
Joey Zalman
Joey Zalman - 01.07.2022 12:21

great video. very clear thank you.

Ответить
MR. Pumpkin pie
MR. Pumpkin pie - 30.06.2022 22:11

Finally! A worthy tutorial!

Ответить
Xx_Legion_xX
Xx_Legion_xX - 24.06.2022 10:11

txt fayl yaratib bo'ladimi???

Ответить
Ausare911
Ausare911 - 23.06.2022 01:36

You always hit the depth level I need on specifics.

Ответить