python 3.4 mod wsgi get SyntaxError: invalid syntax\r

我是研究僧i 提交于 2020-01-06 20:44:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!