0
我一直在嘗試使用各種方法修復此錯誤,但仍找不到任何錯誤。我正在做的是從HTML表單中檢索2個字符串,然後將其作爲JSON發送到我的數據庫。這裏是代碼。Python RecursionError:在調用Python對象時超出最大遞歸深度
HTML表單:
<link rel="stylesheet" href="/static/css/loginstyle.css" type="text/css">
<form action="/registerUser" method="POST">
<div class="login">
<div class="login-screen">
<div class="app-title">
<h1>Register</h1>
</div>
<div class="login-form">
<div class="control-group">
<input type="text" class="login-field" value="" placeholder="Username" name="username">
<label class="login-field-icon fui-user" for="login-name"></label>
</div>
<div class="control-group">
<input type="password" class="login-field" value="" placeholder="password" name="password">
<label class="login-field-icon fui-lock" for="login-pass"></label>
</div>
<input type="submit" value="Register" class="btn btn-primary btn-large btn-block">
<br>
</div>
</div>
</div>
瓶的Python代碼:
sys.setrecursionlimit(1500)
@app.route('/registerUser', methods=['POST'])
def register_user():
if request.method == 'POST':
idx = uuid.uuid4()
uid = str(idx)
username = request.form['username']
password = request.form['password']
password = password.encode('utf-8')
sha1 = hashlib.sha1()
sha1.update(password)
password = sha1.hexdigest()
data = {'uid': uid, 'username': username, 'password': password}
db.child("users").child(username).set(data)
return render_template('/login.html')
else:
error = 'What are you trying to do?'
return render_template('/login.html', error = error)
錯誤:
RecursionError: maximum recursion depth exceeded while calling a Python object
哪一行導致此錯誤? – stamaimer
您是否嘗試過插入日誌語句,以便可以跟蹤執行的確切順序? –