python reptile 006- use debuglog run side-edge printing debug log

# I want to run, run side-edge printing debug log, this time need to open DebugLog 
Import the urllib.request 

# (. 1) and using HTTPHander HTTPSHander debuglevel to set the value. 1 
httphd = urllib.request.HTTPHandler (= debuglevel. 1 ) 
httpshd urllib.request.HTTPSHandler = (debuglevel = 1 ) 

# (2) - the build_opener opener object to create a custom, and with the value (1) as a parameter 
= opener urllib.request.build_opener (httphd, httpshd) 

# (. 3) Create install_opener the global default opener object 
# use our opener installed when so used the urlopen 
urllib.request.install_opener (opener) 

# (. 4) subsequent normal operating 
Data = the urllib.request.urlopen ( " http://edu.51cto.com " )

 

Guess you like

Origin www.cnblogs.com/buzhihuoyu/p/12456143.html