2015年1月2日金曜日

urllib2とurllib問題

python3とpython2でurllibの仕様が変わっているそうですので、メモっておきます。

  import urllib.request                                              # python3
  import urllib2                                                         # python2

  opener  = urllib.request.build_opener()                 #  python3
  opener  = urllib2.build_opener()                            #  python2

  request = urllib.request.Request('http://xxxx')     #  python3
  request = urllib2.Request('http://xxxx')                #  python2

よろしく、お願いいたします。

0 件のコメント:

コメントを投稿