I have a model
class Category(db.Model):
merchandise = db.StringListProperty()
content = db.StringListProperty()
topics = db.StringListProperty()
For instanc开发者_开发百科e, merchandise
list is ["merchandise","tshirt","book","poster"]
I print the list like this
elif merchandise_type == "merchandise":
query = Category.all()
e = query.get()
self.response.out.write("""<ul>""")
for i in range(len(e.merchandise)):
self.response.out.write("""<li><a href="/tag?tag=%s">%s</a></li>"""
% (e.merchandise[i], e.merchandise[i]))
self.response.out.write("""</ul>""")
but I don't want to print "merchandise"
.
How do I start from e.merchandise[1]
instead of e.merchandise[0]
?
Thanks!
for merch in e.merchandise[1:]:
self.response.out.write('<li><a href="/tag?tag=%s">%s<a/></li>' % (merch, merch))
Question, of course, is why do you have such first element in your list in the first place.
for i in range(1, len(e.merchandise)):
changing the first argument of range()
will start the loop from 1 instead of 0
Edit: changed len()
to range()
, silly mistake
精彩评论