2016-05-16 222 views
1

我使用web.py運行以下代碼以獲取mysql數據並將其打印在網頁上。出於某種原因,當我查詢網頁時,我只能看到「無」這個詞。任何想法是什麼問題? MySQL數據庫中有一些數據,憑據是有效的,代碼運行時沒有任何錯誤。Python MySQLdb查詢返回「None」

import web 
import MySQLdb 
import json 
import collections 

db=MySQLdb.connect(user="someuser", 
        passwd="somepass",db="somedatabase") 

urls = (
     '/', 'index', 
     '/test', 'test' 
) 


class index: 
     def GET(self): 
       c=db.cursor() 
       c.execute(""" 
      SELECT email, password 
      FROM users 
      """) 

       rows = c.fetchall() 

Screenshot

回答

2

我覺得你的代碼片段可能是不完整或misformatted,但假設它是沒有的,GET方法沒有return語句,這意味着任何調用將返回None,這又將呈現爲字符串 「無」

+0

是的,這解決了問題。謝謝! – fedorp1