open() examples

open() examples#

Running these examples will create a new file in your workspace or directory.

 # opens an existing text (TXT) file with overwrite permission
 f = open("existing_file.txt", "w")
 # opens an existing CSV file and reads the content
 f = open("existing_file.csv", "r")
 # creates new txt file with write permission
 f = open("new_file.txt", "w")
 # creates new CSV file without write privileges
 f = open("new_file.csv", "x")