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,530 points
116 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 by sahil
• 500 points

Related Questions In Python

0 votes
1 answer
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 in Python by sahil
• 500 points
226 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,540 points
1,944 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,540 points
244 views
+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 6, 2019 in Python by Neha
• 330 points

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