• python模块


    安装模块,使用模块

    The Python Package Index is a repository of software for the Python programming language. There are currently 84841 packages here.

    https://pypi.python.org/pypi

    https://pypi.python.org/pypi/ez_setup

    https://pypi.python.org/pypi/pip

    sudo apt install python-setuptools

    easy_install pip
    pip install django

    pip比easy_install有更好的输出

    下面这个命令可以查询当前所有已安装的模块

    >>> help('modules')

    以下是在ipython中的输入与输出,下面这个命令可以查询相应模块的版本号

    In [3]: import django
    In [4]: django.__version__
    Out[4]: '1.10rc1'
    In [5]: import MySQLdb
    In [6]: MySQLdb.__version__
    Out[6]: '1.2.4b5'

    os模块
    /usr/lib64/python2.7/os.py
    re模块
    pickle模块
    pkg_resources模块
    /usr/lib/python2.7/site-packages/pkg_resources.py

    socket

    SocketServer是对上面的封装实现

    httplib

    urllib2是对上面的封装实现

    import urllib2
    op=urllib2.build_opener()
    f=op.open("http://www.fltdz.com/index.html")
    f.read()

    import MySQLdb

    yum安装MySQLdb模块
    yum install python-devel mysql-devel
    yum install MySQL-python

    源码安装MySQLdb模块

    yum install python-devel mysql-devel
    wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.4b5.tar.gz#md5=2d760ee948aff4f50d01afdf8afff48c
    tar zxvf MySQL-python-1.2.4b5.tar.gz
    cd MySQL-python-1.2.4b5
    python setup.py build
    python setup.py install


    [root@103-c7 first]# python con.py
    (('5.1.73',),)
    [root@103-c7 first]# cat con.py
    import MySQLdb
    #db=MySQLdb.connect(host='192.168.10.104',user='root',password='123456',db='mysql')
    db=MySQLdb.connect('192.168.10.104','root','123456','mysql')
    cursor=db.cursor()
    cursor.execute('select host,user,password from user')
    result=cursor.fetchall()

    for row in result:
            host=row[0]
            user=row[1]
            password=row[2]
            print 'user=%s,host=%s,password=%s' %(user,host,password)

    #print result cursor.close() db.close()

    http://www.cnblogs.com/ccdc/p/4069112.html
    yum install python-devel
    yum install libjpeg libjpeg-devel zlib zlib-devel freetype freetype-devel lcms lcms-devel
    yum install python-imaging

    当您希望与 Web 页面中找到的内容进行某种比较复杂的交互时,您需要使用 mechanize 库
    
    [root@kvm1 python]# easy_install mechanize
    Searching for mechanize
    Reading https://pypi.python.org/simple/mechanize/
    Best match: mechanize 0.2.5
    Downloading https://pypi.python.org/packages/ca/fd/edbcc1abd5bbfc0e19fb3a8d3eebfd11d7d1ce9c8f24c0f54e8db09956b3/mechanize-0.2.5.zip#md5=a497ad4e875f7506ffcf8ad3ada4c2fc
    Processing mechanize-0.2.5.zip
    Writing /tmp/easy_install-F_4XQm/mechanize-0.2.5/setup.cfg
    Running mechanize-0.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-F_4XQm/mechanize-0.2.5/egg-dist-tmp-ZkMUJd
    Adding mechanize 0.2.5 to easy-install.pth file
    
    Installed /usr/lib/python2.7/site-packages/mechanize-0.2.5-py2.7.egg
    Processing dependencies for mechanize
    Finished processing dependencies for mechanize
    
    
    /usr/lib/python2.7/site-packages/mechanize-0.2.5-py2.7.egg/mechanize/__init__.py
    
    
    
  • 相关阅读:
    AppCrawler自动化遍历使用详解(版本2.1.0 )
    python 接口测试1 --如何创建和打印日志文件
    通过Xshell登录远程服务器实时查看log日志
    java基础知识6-- 抽象类,抽象方法,接口,构造方法,类方法等易混淆的知识点
    java基础知识5--集合类(Set,List,Map)和迭代器Iterator的使用
    java基础知识4--数组的常用方法(Array)
    java基础知识3--如何获取资源文件(Java中获取资源文件的url)
    java基础知识2--String,StringBufffer,StringBuilder的区别
    java基础知识1--String常用方法总结
    javascript正则表达式验证密码(必须含数字字符特殊符号,长度4-16位之间)
  • 原文地址:https://www.cnblogs.com/createyuan/p/5692556.html
Copyright © 2020-2023  润新知