Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 1111 Introduction to Programming Spring 2019

Similar presentations


Presentation on theme: "CS 1111 Introduction to Programming Spring 2019"— Presentation transcript:

1 CS 1111 Introduction to Programming Spring 2019
Reading from Internet CS 1111 Introduction to Programming Spring 2019

2 File Processing (Local)
Repeated process Open a file Read contents of a file Process the content Write/append content to another file Close a file

3 File Processing (Internet)
Repeated process Open a file Read contents of a file Decode the content Process the content

4 Opening Files (Internet, via URLs)
import urllib.request url = some-url-to-the-file stream = urllib.request.urlopen( url) for line in stream: decoded = line.decode("UTF-8") print(decoded.strip())

5 Summary Read from files -- Must know (based on exam2 topic list, as of 03/27/2019) open(filename) connection.read() connection.readline() ways of iterating lines connection.readlines() connection.read().split('\n') for line in connection Read from the Internet -- Must know (based on exam3 topic list, as of 03/27/2019) import urllib.request urllib.request.urlopen(url) stream.read().decode('utf-8')


Download ppt "CS 1111 Introduction to Programming Spring 2019"

Similar presentations


Ads by Google