-2
在第7行中,我得到了錯誤'return'外部函數,我嘗試了縮進,這不是問題,所以我不確定是什麼?'return'外部函數錯誤 - python
import psycopg2
from flask import Flask, render_template, request
app = Flask(__name__)
def getConn():
connStr=("dbname='----' user='----' password= '----' ")
conn=psycopg2.connect(connStr)
return conn
@app.route('/')
def home():
return render_template('part3.html')
@app.route('/displayStudent', methods =['GET'])
def displayCustomer():
@app.route('/addStudent', methods =['GET', 'POST'])
def addLeadCustomer():
if __name__ == "__main__":
app.run(debug = True)
檢查您的縮進。 'return conn'具有縮進,但它不在任何函數中。 – Dmitry
在第7行返回之前點擊,然後點擊標籤鍵或空格4次 – WhatsThePoint
修復您的縮進。 –