In the 8.04.4 environment (in fact, I think it is not related to the environment, I have a problem with the sentence):
$ dpkg-l | Grep-i python
II Libapache2-mod-python 3.3.1-2build1 Apache 2 module that embeds python within th
II Moinmoin-common 1.5.8-5.1ubuntu2.5 Python clone of Wikiwiki-common data
II Python 2.5.2-0ubuntu1 an interactive high-level object-oriented LA
II python-apt 0.7.4ubuntu7.7 python interface to libapt-pkg
II Python-central 0.6.7ubuntu0.1 Register and build utility for Python Packag
II Python-django 0.96.1-2ubuntu2.1 A High-level python WEB framework
II python-gdbm 2.5.2-0UBUNTU2 GNU dbm database support for Python
II Python-gnupginterface 0.3.2-9ubuntu1 Python interface to GnuPG (GPG)
II Python-minimal 2.5.2-0UBUNTU1 A Minimal subset of the Python language (def
II Python-moinmoin 1.5.8-5.1ubuntu2.5 python clone of Wikiwiki-library
II python-mysqldb 1.2.2-5ubuntu1 A python interface to MySQL
II Python-support 0.7.5UBUNTU1 Automated rebuilding support for Python Modu
II python2.5 2.5.2-2ubuntu6.2 An interactive high-level object-oriented LA
II Python2.5-minimal 2.5.2-2ubuntu6.2 A Minimal subset of the Python language (ver
Wrote a small program that wants to read the name and mail that appear in the users table of their database.
cat/var/www/dbtest.py
#!/usr/bin/python
db = MySQLdb.connect (host= "localhost", user= "XXXX", passwd= "passwd****", db= "Mymanualdb")
cursor = Db.cursor ()
Cursor.execute ("Select name, mail from users")
result = Cursor.fetchall ()
For record in result:
Print record[0], "--", record[1]
But the actual always error, do not know where the problem?
$ python/var/www/dbtest.py
File "/var/www/dbtest.py", line 11
Print record[0], "--", record[1]
^
Indentationerror:expected an indented block
This article is from the "Windmill in the Wilderness" blog, please make sure to keep this source http://moorwindmill.blog.51cto.com/2272071/1411806