CSCA20H3 Study Guide - Final Guide: Backslash

655 views2 pages
25 Feb 2016
School
Course

Document Summary

Csca20 general programming: files, open a file: To write replaces file filename open_file = open( filename. txt", w") To append open_file = open( filename. txt", a") my_file. close(: reading files: my_file = open( filename", r") # retrieving individual data for line in my_file: close file after finishing: # split each word/data at whitespace each_line = line. split() # indexed line refers to all data in column i" specific_data = each_line[i] # read whole file at once as list of strings list_of_lines = my_file. readlines() # read file one line at a time line = my_file. readline() # read entire file as a string s = my_file. read() # but each line is a list: invisible characters, tab , new line \n, single quote \", double quote \ , backslash \, tuples like lists, but use parenthesis and are immutable. >>> t[0] = anna": look up entries, add entry, dictionaries have unique (key:value) pair emissions[1905] or emissions. get(1905) # enter a specific value to corresponding key d[key] = value.

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

Related Documents

Related Questions