CISC 121 Lecture Notes - Lecture 10: Text File

24 views1 pages
wunch and 39345 others unlocked
CISC 121 Full Course Notes
35
CISC 121 Full Course Notes
Verified Note
35 documents

Document Summary

Tracing the paths of where files are on the computer. Shift right click to copy as path on document/file. Text file: think as like a long string. Input/ output: associate the file with an object in the program, read and write, close the file. When we open the file in python it opens a file object. infile=open( thepathofthefilewewanttouse , r") The r here stands for read because we are opening it as a read file. We also need a file mode (read, write, or append) We open the file differently for reading then if we are going to write the file. In windows computers once we get the file path change the \ to / before opening it. Infile. read() reads all characters and returns string. Infile. readlines() outputs each line as elements in a list. Infile() important proper practice and when trying to write files in order to make the changes the file must be closed.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions