1. Pickle Difference
In Python 2.7, the Dict object is stored serialized, and then free to serialize, with the following code in general:
However, when you invoke the above code in Python 3.5, you will report the following error:
This is the default for the 2.7pickle.load function read bytes read, while 3.5 read the default for ASCII read, the official website description is as follows:
So you just need to change the read format of the call to bytes.
Wind = pickle.load (pkl_file,encoding= ' bytes ')
2. URL access is different
In Python2.7, the request code for a URL is as follows:
Importurllib2
req = Urllib2. Request (' http://www.baidu.com ')
Response = Urllib2.urlopen (req)
Instead of using request in 3.5, the code is as follows:
From Urllibimportrequest
req = Request. Request (Req_url)
f= Request.urlopen (req)
And there is a more convenient way to access, you can avoid the lack of timely closure of the link, the code is as follows:
from Import Request
with as F:
data = F.read ()
Print (' Status: ', F.status, F.reason)
for in F.getheaders ():
Print ('%s:%s '% (k, v))
Print (' Data: ', Data.decode (' Utf-8 '))
Access with AS: To automatically close links when page access is complete