python3 开发环境配置

Python026

python3 开发环境配置,第1张

安装pip

第一步: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

第二步: sudo python3 get-pip.py

第三部:终端输入 pip 校验

安装tkinter

第一步: brew install [email protected]

第二步: brew install tcl-tk

第三部: python -m tkinter

def openUrl(url):

    import urllib2

    url = 'http://' + url

    req = urllib2.Request(url)

    //根据你自己的需要设置header,add_header方法中需要两个参数,key和value的键值对

    req.add_header('User-agent', 'Mozilla/5.0 (Windows NT 6.2 WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1707.0 Safari/537.36')

    response = urllib2.urlopen(req)

    the_page = response.read()

    print the_page

    print response.geturl()

    print response.info()

    print response.headers

openUrl('xxx.xxx.xxx')