2016-09-21 57 views
0

不通過user_nameother_function作爲參數,我將如何訪問user_name在調用函數外部訪問Flask參數

@app.route('/profile/<user_name>/') 
def profile(user_name): 
    other_function() 
    # do more stuff 

def other_function(): 
    print request.args 

回答

1

您可以通過request.view_args達到視圖參數,這是一本字典:

def other_function(): 
    print request.view_args['user_name']