代码其实很简单,只有一小段,是在pycharm上运行的,所用的python版本为2.7,mysql版本为5.7.21
# -*- coding: UTF-8 -*-
import re
import MySQLdb
if __name__ == '__main__':
#打开数据库
conn = MySQLdb.connect(host='localhost',port=3306,user='root',passwd='1234567',db='shixiseng')
cursor = conn.cursor()
cursor.close()
conn.close()
运行后代码报错:
Traceback (most recent call last):
File "C:/Users/Braggart/PycharmProjects/exercise/33.py", line 57, in <module>
conn = MySQLdb.connect(host='localhost',port=3306,user='root',passwd='1234567',db='shixiseng')
File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\P