File Handling using Python
Basic File Open Syntax.
Basic Syntax for 'with' and 'as' keyword while open a file:
- File can open in Write mode which works as Over Write file content with String you Pass in syntax.
Syntax:
with open('demo.txt') as file:
file.write("String here")
- Another important feature of write mode is that if file does not exist then it will be added empty file at the Current folder in which you are working.
Append Mode :
- Files can open in append mode which includes write method.
Syntax :
with open('demo.txt", mode='a') as file:
file.write("Appended String Here")
Comments
Post a Comment