标签:
下面这个命令可以查询当前所有已安装的模块
>>> 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()
标签:
原文地址:http://www.cnblogs.com/createyuan/p/5692556.html