head first series 学习记录(Python)

1.缩进很重要

2.输入的时候需要加上引号

3.page 40

这样写不对。

import urllib2
page=urllib2.urlopen("http://www.beans-r-us.biz/prices.html")
text=page.read().decode("utf8")
print(text)

这样还是不对。

import urllib2
page=urllib2.urlopen('http://www.beans-r-us.biz/prices-loyalty.html')
text=page.read().decode('big5').encode('utf8')     //text=page.read().encode('utf8')

price=text[234:238]
print(price)

 

把网址换成可以正常访问的就okay。

4.page 57讲了一些方法。

5.twitter那个例子没有看。  ~page 1026

6.后面也没有看。 ~111

7.大概在page 153的这一段  

scores={}
scores[8.45]='Joseph'
scores[9.12]='Juan'
scores[7.21]='Zack'
for key in scores.keys():
    print(scores[key]+' had a score of '+str(name_part))
for score, suffer in scores.items():
    print(suffer+' had a score of '+str(score))
  运行不成功,我也不明白那个 name_part是什么意思。

 

 

 

            

注:

urllibPython 2 namePython 3 name
urllib.urlopen() Deprecated. See urllib.request.urlopen() which mirrorsurllib2.urlopen()
urllib.urlretrieve() urllib.request.urlretrieve()
urllib.urlcleanup() urllib.request.urlcleanup()
urllib.quote() urllib.parse.quote()
urllib.quote_plus() urllib.parse.quote_plus()
urllib.unquote() urllib.parse.unquote()
urllib.unquote_plus() urllib.parse.unquote_plus()
urllib.urlencode() urllib.parse.urlencode()
urllib.pathname2url() urllib.request.pathname2url()
urllib.url2pathname() urllib.request.url2pathname()
urllib.getproxies() urllib.request.getproxies()
urllib.URLopener urllib.request.URLopener
urllib.FancyURLopener urllib.request.FancyURLopener
urllib.ContentTooShortError urllib.error.ContentTooShortError

 

 

今天晚上看到page200,明天 come on!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值