例如,我了解可以通过
检索html://www.test.com/?color=red
的POST
color=self.request.get('color')
#print color would output red
相反,我试图获得像html://www.test.com/?colors=red,orange,yellow,green,blue,violet
这样的东西
colors=self.request.get('colors')
for color in colors:
#the first loop color=red
#the second loop color=orange
#and so on
非常感谢任何建议。提前谢谢!
答案 0 :(得分:1)
对于这样一个简单的案例,你可以使用:
for color in colors.split(","):
# the first loop color=red
# the second loop color=orange
# and so on