1

Python 2.7 と mysql-python 2.7 をインストールしました。このコードを実行して、Python で MySQL をテストします。

import MySQLdb
db = MySQLdb.connnect(host = "localhost",
                      user="Bishnu Bhattarai",
                      passwd = "password",
                      db = "student")
cursor =db.cursor()
cursor.execute("select * from basic_info" )
numrows = int(cursor.rowcount)
for x in range(0,numrows):
    row = cursor.fetchall()
    print row[0],"-->",row[1]

しかし、それはエラーを示しています:

Traceback (most recent call last):
  File "C:\Users\Bishnu\Desktop\database", line 2, in <module>
    db = MySQLdb.connnect(host = "localhost",
AttributeError: 'module' object has no attribute 'connnect'

何が問題ですか?

4

1 に答える 1

5

から3番目の「n」を削除してみてくださいconnect:)

于 2013-01-23T09:12:24.533 に答える