我要编写自定义key_func。
如果URL像:http://www.example.com/aaa/?bbb=xxx,并且我想使用bbb的值作为键。我可以这样写:
structure(list(date = structure(c(-15890, -15890, -15890, -15890,
-15859, -15859, -15859, -15859, -15828, -15828, -15828, -15828,
-15798, -15798, -15798, -15798), class = "Date"), type = c("Small; Low",
"Small; 2", "Small; 3", "Small; 4", "Small; Low", "Small; 2",
"Small; 3", "Small; 4", "Small; Low", "Small; 2", "Small; 3",
"Small; 4", "Small; Low", "Small; 2", "Small; 3", "Small; 4"),
y = c(3.78, -0.41, -1.94, 0.35, -2.21, -8.73, 2.44, 0.61,
-6.21, -0.3, -6.2, -1.64, -8.62, -3.75, -5.67, 5.72), x1 = c(1.28446741361197,
1.07356662903464, 1.04832788500252, 0.943639719875559, 1.28446741361197,
1.07356662903464, 1.04832788500252, 0.943639719875559, 1.28446741361197,
1.07356662903464, 1.04832788500252, 0.943639719875559, 1.28446741361197,
1.07356662903464, 1.04832788500252, 0.943639719875559), x2 = c(1.44263144125512,
1.52425318619375, 1.24887757539023, 1.20367883758503, 1.44263144125512,
1.52425318619375, 1.24887757539023, 1.20367883758503, 1.44263144125512,
1.52425318619375, 1.24887757539023, 1.20367883758503, 1.44263144125512,
1.52425318619375, 1.24887757539023, 1.20367883758503), x3 = c(0.430576566887732,
0.237649845254604, 0.520660917641051, 0.588602620999144,
0.430576566887732, 0.237649845254604, 0.520660917641051,
0.588602620999144, 0.430576566887732, 0.237649845254604,
0.520660917641051, 0.588602620999144, 0.430576566887732,
0.237649845254604, 0.520660917641051, 0.588602620999144)), row.names = c(NA,
-16L), class = c("tbl_df", "tbl", "data.frame"))
如果URL类似于http://www.example.com/aaa/<bbb>,而我仍想使用bbb的值作为键怎么办?
路由功能将是:
def my_key_func():
return request.args.get('bbb')
如何将bbb传递给my_key_func?