當我運行時,每次 TypeError: job() missing 1 required positional argument: 'count' 時都會出現此錯誤
count = 0
@app.route('/v1.1/userRegistor', methods=['POST', 'GET'])
def job(count):
data = request.get_json()
numbers = data['number']
if count == 0:
api2_url = f'https://app.simplywhatsapp.com/api/send.php?number={numbers}&type=text&message=Your OTP is {value}&instance_id=api2&access_token=api2'
r = requests.get(api2_url).text
count = 1
uj5u.com熱心網友回復:
您的 @app.route 沒有定義要提供的計數引數,但您的job()函式需要一個引數。
例如,對于路徑引數,您可以通過以下方式在路由中定義計數:
@app.route('/v1.1/userRegistor/<count>', methods=['POST', 'GET'])
uj5u.com熱心網友回復:
該錯誤表明您的 URL 需要 count 引數,因此可能類似于:
@app.route('/v1.1/userRegistor/<count>', methods=['POST', 'GET'])
在此處查看建議的答案
uj5u.com熱心網友回復:
那是因為你的函式 job(count) 需要一個輸入變數 count ,它期望用戶發送請求。
利用
count = 0
@app.route('/v1.1/userRegistor', methods=['POST', 'GET'])
def job():
global count
data = request.get_json()
numbers = data['number']
這樣您就可以將全域變數傳遞給函式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/519581.html
標籤:Pythonapi烧瓶
