Python Tutorial - 13. Reading/Writing Files

preview_player
Показать описание
In this python tutorial, we will clarify about reading/ writing files, how to work with a file, how to open, create and close a file, use of “functions”, “modules” and “flags”.

Topics that are covered in this Python Video:
0:00 Overview
0:32 Open() function
1:35 write() function
1:51 close() function
2:54 append mode in a file
4:06 read from a file
5:10 read mode in a file
5:35 read() function
7:19 Split() function
11:50 File opening modes
13:23 with statement
14:16 close Flag in file

Next Video:

Рекомендации по теме
Комментарии
Автор

8 years ago and still reliable is pretty awesome

smaransure
Автор

Thank you so much. you are the best teacher I've even seen. Good luck.

nastaran
Автор

Then that has a special meaning and it will not work
👌👌👌👌
What an explanation

abdevilliers
Автор

Very good, thank you! The background music was a nice addition too :)

ethan
Автор

Here is the solution

for line in f:
words = line.strip().split() # Remove trailing newline and split into words
word_count = len(words)
f_out.write(line.strip() + " wordcount " + str(word_count) + "\n") # Append word count and newline

f.close()
f_out.close()

igormarkaryan
Автор

Sir can u explain why u have used Double slash in path here but only single slash for path when we were dealing with modules

riyaprem
Автор

Thank you Sir. There is a procedural bug. The previous tutorial should have come after this one. Kindly adjust the playlist.

sheikhabdullah
Автор

Thanks for this great video, you helped me for my assignment

dig
Автор

ur vids r great to watch...ty fr such great wrk

FurqaanShafi
Автор

Hello. Please remove the background music and keep this video like the rest videos. Thanks indeed.

amra.haleem
Автор

Great explanation. Would you be able to create a tutorial on reading values in a text file using splitlines, previous_lines nested in a for loop. Basically how to take field name & respective value from a text file and output them into a pandas dataframe.

jaggyjut
Автор

Hi Sir,
Love your content as always...great video..
I have few questions regarding the example you have taken in this video:
If expand the conversation in the example taken
Using text file handling and string manipulation in python
1) How can I find the number of unique speaker and list of all speaker present in file and also want separate file for each speaker.
2) I want to find the list of all unique words spoken by each unique speaker in new line and want to save these words in respective speaker's file .
3) how to remove all punctuations.

If I will get the answer it will be great help.
Thanks in advance....

reviewguru
Автор

Can you please share solution for sample exercise? Thanks.

yashdeepy
Автор

The easiest one on youtube! Loved it..

bikonkumardas
Автор

for exercise 1 and 2 you put the same solution please change that one

work-dwhl
Автор

solution:
def Countnum(num):
k = open("C:\\input.txt")
number = k.readlines()
number = [x.strip() for x in number]
count =0
for i in number:
if i.__contains__(str(num)):
count = count +1
print(count)

devesh_upreti
Автор

Thanks a lot man for helping us, and i wish that allah help you also.

younessaznag
Автор

Hi, I cannot perform this action using a macbook/apple computer. Are there additional instructions for Mac users?

chineduokpala
Автор

Hi, in the exercise section solution to 1st problem linked to wrong link (when you press it open solution for problem 2)

olgaggg
Автор

Hi sir, you're tutorial is very educating, do you know how to delete a letter in a text file?

jomarcristianerandio