CISC 121 Chapter Notes - Chapter 14: Dbm, John Cleese

84 views3 pages
wunch and 39345 others unlocked
CISC 121 Full Course Notes
35
CISC 121 Full Course Notes
Verified Note
35 documents

Document Summary

Chapter 14: files: run for a long time, at least some data in permanent storage, if restarted, pick up where left off, ex. Operating systems, web servers: usually done by reading and writing text files. Alternatively databases are used: open a file using (cid:494)w(cid:495) toopen = open(cid:523)(cid:494)output. txt(cid:495), (cid:494)w(cid:495)(cid:524) Opening in (cid:494)write(cid:495) mode clears out old data. Line(cid:883) = (cid:494)this here(cid:495)s the wattle, \n(cid:495) toopen. write(line1) Returned is the number of characters written: closing a file toopen. close() Format operator: must convert all inputs of . write() to string. %d formats an integer, %g formats a floating-point number, %s formats a string: camels = 42. Camels value made a string (cid:494)%d(cid:495) % camels (cid:494)(cid:886)(cid:884)(cid:495) (cid:494)) have spotted %d camels. (cid:495) % camels (cid:494)) have spotted (cid:886)(cid:884) camels. (cid:495) (cid:494)%d %d %d(cid:495) % (cid:523)(cid:883), (cid:884), (cid:885)(cid:524) elements must have the same number. When more than one format operator is used, a tuple of.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents