Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

with python

# file handling 
  
# 1) without using with statement 
file = open('file_path', 'w') 
file.write('hello world !') 
file.close() 
  
# 2) without using with statement 
file = open('file_path', 'w') 
try: 
    file.write('hello world') 
finally: 
    file.close() 
    
# using with statement 
with open('file_path', 'w') as file: 
    file.write('hello world !') 
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
5+6 =