Download presentation
Presentation is loading. Please wait.
Published byArnold Whitehead Modified over 5 years ago
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')
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.