**
    
    
    python2与python3导包的一些区别
   
    **
    
    
     
      问题描述:
     
    
    
    有两个版本,python2和python3,虽然要用的模块不尽相同,但是封装的包是不一样的,要自己仔细看看呦
    
    这是一个程序跑不起来的重要因素,后面遇到新的不同点会更新。
    
    
     这里显示的是python3的相应包和模块
    
   
    
     目录:
    
    
    1、htmlentitydefs
    
    2、cookielib
    
    3、urllib2
    
    4、urlencode
    
    5、HTMLParser
    
    6、unichr
   
    
     
      1、htmlentitydefs
     
    
    
    ImportError: No module named ‘htmlentitydefs’
    
    同样也是导入codepoint2name的出错点
    
    
    
    在这个包里的entitles模块里面
    
    
     
      2、cookielib
     
    
    
    ImportError: No module named ‘cookielib’
    
    Python3中,
    
     import cookielib 改成 import http.cookiejar,将所有cookielib
     
      也改成 http.cookiejar
      
      
       
        3、urllib2
       
      
      
      Python 3中
     
     urllib2 用urllib.request
    
    替代。
    
    
     
      4、urlencode
     
    
    
    AttributeError: module ‘urllib’ has no attribute ‘urlencode’
    
    不在一个模块里面
    
    在这
    
    
    
    
     
      5、HTMLParser
     
    
   
from HTMLParser import HTMLParser #python2
from html.parser import HTMLParser #python3
    
     
      6、unichr
     
    
    
    NameError: name ‘unichr’ is not defined
    
    Python2中使用的chr()将Ascii的值转换成对应字符,unichr()将Unicode的值转换成对应字符
    
    我们发现Python3中的chr()不仅仅支持Ascii的转换,并且直接支持了更为适用的Unicode转换。
   
 
