Important Notice:

Append Mode — a

Append Mode — a

2 views 1 min read

Append Mode — a :-

Append Mode का उपयोग existing file के अंत में नया data जोड़ने के लिए किया जाता है। इस mode में पहले से मौजूद data delete नहीं होता।

यदि file मौजूद नहीं है, तो Python नई file create करता है।

English:

Append mode is used to add new data at the end of an existing file without deleting its previous content. If the file does not exist, Python creates a new file.

Syntax -

file = open("filename.txt", "a")

Example

मान लीजिए student.txt में पहले से यह data है:

Rahul
Amit

Python Program:

file = open("student.txt", "a")

file.write("\nSohan")

file.close()

Updated File Content:

Rahul
Amit
Sohan

Important Points

  1. a का अर्थ Append Mode है।

  2. यह file के अंत में data जोड़ता है।

  3. Existing data delete नहीं होता।

  4. File मौजूद नहीं होने पर नई file बनाता है।

  5. Append mode में writing file के अंत में होती है।

Related Notes