KnowledgeBoat Logo

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

1 Like


Related Questions