首页 > 编程语言 > 详细

python模块

时间:2016-07-21 19:30:48      阅读:148      评论:0      收藏:0      [点我收藏+]

 

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

>>> 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‘

 

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()

 

python模块

原文:http://www.cnblogs.com/createyuan/p/5692556.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!