2016-09-21 63 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']