Computer Science
Write a program to add two more employees' details (empno, ename, salary, designation) to the file "emp.txt" already stored in disk.
Python Data Handling
3 Likes
Answer
Let the file "emp.txt" include the following sample text:
1001, Ankit Singh, 50000, Manager
1002, Neha Patel, 45000, Developer
file = open("emp.txt", "a")
file.write("1003, Manoj Tiwari, 48000, Analyst\n")
file.write("1004, Aarti Gupta, 52000, Engineer\n")
The file "emp.txt" include the following text:
1001, Ankit Singh, 50000, Manager
1002, Neha Patel, 45000, Developer
1003, Manoj Tiwari, 48000, Analyst
1004, Aarti Gupta, 52000, Engineer
Answered By
2 Likes
Related Questions
Write a method in Python to read the content from a text file diary.txt line by line and display the same on screen.
Write appropriate statements to do the following:
(a) To open a file named "RESULT.DAT" for output.
(b) To go to the end of the file at any time.
How are the following codes different from one another?
1.
fp = open("file.txt", 'r') fp.read()
2.
fp = open("file.txt", 'r')
What is the output of the following code fragment? Explain.
fout = open("output.txt", 'w') fout.write("Hello, world! \n") fout.write("How are you?") fout.close() f = open("output.txt") print(f.read())