python 操作python

#!/usr/bin/env python
#_*_ coding:utf-8 _*_

import MySQLdb

# 打开门
conn = MySQLdb.connect(host='192.168.1.21',user='yangqw',passwd='1',db='free')

# 伸出手
cur = conn.cursor()

# 对数据进行操作
reCount= cur.execute('select * from student')
data = cur.fetchall()

# 伸回手
cur.close()

# 关上门
conn.close()

print reCount
print data

原文地址:https://www.cnblogs.com/yycc/p/7302641.html