所以,我今天才开始使用 python。我安装了,python-mysql.connector
所以我可以开始编写一些查询并在 python 中处理结果,然后将一些数据输出到液晶屏幕。
知道这就是我所拥有的......
#!/usr/bin/python
import Adafruit_CharLCD
import mysql.connector
class LCDTests:
def __init__(self):
self.lcd = Adafruit_CharLCD;
#self.lcd.begin(16,1);
try:
cnx = mysql.connector(user = '', password='' database='', host='')
except mysql.connector.Error, e:
try:
print "MySQL Error [%d]: %s" % (e.args[0], e.args[1])
except IndexError:
print "MySQL Error: %s" % str(e)
else:
cnx.close()
def run(self):
print('alex')
#lcd.message('loading...');
test = LCDTests()
test.run()
但是每当我跑步时,./test.py
我都会不断得到以下输出:
Traceback (most recent call last):
File "./test.py", line 31, in <module>
test = LCDTests()
File "./test.py", line 16, in __init__
cnx = mysql.connector(user = '...', password='...', database='...', host='...')
TypeError: 'module' object is not callable
在搜索问题时,我发现什么都没有真正帮助我解决问题......问题可能出在哪里的任何想法?