INFO1110 Lecture Notes - Lecture 4: Working Directory, Root Directory, Order Of Merit
Document Summary
Lomoarcpsd|7290020: absolute path (from root directory, \, relative path (relative destination from current working directory) When you open a le for reading (read mode), the program assumes the le exists and you have permission to read from the le. When you open a le for writing (write mode), you always begin with an empty le: if le already exists, program will override, if le does not exist, program will create it. To add to the end of an existing le, you will want to append (append mode). The following code writes the string contents to a le called sample. txt. After running the below command in your terminal, you should be able to see a new le with the ls command. We use the open function to open a le. The open function takes a lepath as its rst argument and a mode as the second argu- ment.