How do you read from a file using file handling in python

0 votes
What is the syntax to write in a text file?
Jul 22, 2019 in Python by Waseem
• 4,540 points
895 views

2 answers to this question.

0 votes

To read from a file you can use the following command.

#file.read()
file = open('filename', "r")

To write into a file, you can use the following code.

file = open("filename", "w")
file.write("what you want to write")
file.close()


answered Jul 30, 2019 by Mohammad
• 3,230 points
0 votes

for write, read,append data in file check geekindian.com file handling lecture and for advance feature of file handling check shutil module lecture

answered Jun 21, 2020 by sahil
• 580 points

Related Questions In Python

–1 vote
2 answers
0 votes
2 answers

In Python, how do I read a file line-by-line into a list?

readline function help to  read line in ...READ MORE

answered Jun 21, 2020 in Python by sahil
• 580 points
1,437 views
0 votes
1 answer

How to use read a WSDL file from the file system using Python suds?

Hi, good question. It is a very simple ...READ MORE

answered Jan 21, 2019 in Python by Nymeria
• 3,560 points
7,674 views
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29, 2019 in Python by Nymeria
• 3,560 points
1,754 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,023 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,420 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP