Append and Read Mode — a+ :-
a+ Mode का उपयोग file को पढ़ने और उसके अंत में नया data जोड़ने के लिए किया जाता है। यदि file मौजूद नहीं है, तो Python नई file create करता है। Existing data delete नहीं होता।
English:
The a+ mode is used to open a file for both reading and appending. New data is added at the end of the file without deleting existing content.
Syntax
Explanation
a+ से file reading और appending दोनों के लिए open हुई।
write() ने file के अंत में नया data जोड़ा।
seek(0) ने reading के लिए position शुरुआत में की।
read() ने पूरा data पढ़ा।
close() ने file बंद कर दी।
Important Points
Reading और appending दोनों कर सकते हैं।
Existing data delete नहीं होता।
नया data file के अंत में जोड़ा जाता है।
File मौजूद नहीं होने पर नई file create होती है।
Reading के लिए seek(0) उपयोगी है, क्योंकि append mode में initial position file के अंत में होती है।