问题
When I run the following code I get a syntax error:
def application(environ, start_response):
result = ChildClass().getValue()
status = '200 OK'
output = result
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
print(output)
return [output]
class ChildClass(): # define child class
print('ppp')
def __init__(self):
print("Calling child constructor")
def childMethod(self):
print('Calling child method')
#Parentclass().parentMethod()
def getValue(self):
# Open database connection
db = mysql.connector.connect(user='root', password='55118',host='127.0.0.1',database='test')
cursor = db.cursor()
query = ("SELECT * from employees2")
cursor.execute(query)
#for (first_name) in cursor:
return result = cursor.fetchall()
It doesn't accept the return : return result = cursor.fetchall()\r SyntaxError: invalid syntax\r
来源:https://stackoverflow.com/questions/31918319/python-3-4-mod-wsgi-get-syntaxerror-invalid-syntax-r