聲明
- Python版本2.7.3
- 所需Py文件——urllib2
- 2.7.3版本的Python Shell即可直接執行,但需要聯網
- 若程序執行成功,則會下載以下網址的txt文本並打印在shell中
- 本代碼來源於《父與子的編程之旅——與小卡特一起學》(這是一本國外的很不錯的Python入門著作)
file:///C:/Users/ouni/下載/父與子的編程之旅:與小卡特一起學%20Python.epub
import urllib2
file=urllib2.urlopen('http://helloworldbook2.com/data/message.txt')
message=file.read()
print message