py代码 @app.route(‘/usercenter/<user_id>/<tag>‘) @loginFirst def usercenter(user_id,tag): user = User.query.filter(User.id==user_id).first context ={ ‘user‘:user } if tag ==‘1‘: return render_template(‘usercenter1.html‘, **context) elif tag ==‘2‘: return render_template(‘usercenter2.html‘, **context) else: return render_template(‘usercenter3.html‘, **context) html代码 <ul class="nav_ul"> <li role="presentation"><a href="{{ url_for(‘usercenter‘,user_id= user.id,tag=1) }}">全部提问</a></li> <li role="presentation"><a href="{{ url_for(‘usercenter‘,user_id= user.id,tag=2) }}">全部评论</a></li> <li role="presentation"><a href="{{ url_for(‘usercenter‘,user_id= user.id,tag=3) }}">个人信息</a></li> </ul> <a href="{{ url_for(‘usercenter‘,user_id=foo.author_id,tag=1)}}">{{ foo.author.username}}</a> <a href="{{ url_for(‘usercenter‘,user_id= session.get(‘id‘),tag =1) }}">{{ session.get(‘user‘) }}</a>