Section 5.12 π©βπ» Tips on Handling Files
When working with files, there are a few things to keep in mind. When naming files, itβs best to not include spaces. While most operating systems can handle files with spaces in their names, not all can.
Additionally, suffixes in files names, for example the .txt in
FileNameExample.txt
, are not magic. Instead, these suffixes are a convention. For some operating systems the suffixes have no special significance, and only have meaning when used in a program. Other operating systems infer information from the suffixes - for example, .EXE
is a suffix that means a file is executable.Itβs a good idea to follow the conventions. If a file contains CSV formatted data, name it with the extension
.csv
, not .txt
. A Python program will be able to read it either way, but if you follow the convention you will help other people guess whatβs in the file. And you will also help the computerβs operating system to guess what application program it should open when you double-click on the file.You have attempted of activities on this page.