如何将变量数组/对象传递给python(谷歌应用程序引擎)

时间:2014-05-30 21:51:35

标签: python google-app-engine

例如,我了解可以通过

检索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

非常感谢任何建议。提前谢谢!

1 个答案:

答案 0 :(得分:1)

对于这样一个简单的案例,你可以使用:

for color in colors.split(","):
    # the first loop color=red
    # the second loop color=orange
    # and so on