我有个问题。你知道吗
我有两个ndb.模型具有这些属性。你知道吗
class DatesPrices(ndb.Model):
startDate = ndb.DateProperty
endDate = ndb.DateProperty
class Hotel(ndb.Model):
datesAndPrices = ndb.StructuredProperty(DatesPrices, repeated=True)
因此,我需要创建一个新的酒店实体,并在其StructuredProperty属性中放置几个“datesAndPrices”模型(可以是任意数量)。你知道吗
那么我怎样才能通过“for循环”把它放进去呢?你知道吗
hotel = Hotel()
for x in range(0, someRandomCounter):
hotel.datesAndPrices.append(DatesPrices(startDate ='',
startDate =''));
hotel.put()
????
这是正确的吗?我能加上它吗?或者?你知道吗
我会感激任何帮助!谢谢。你知道吗
是的。一旦拥有StructuredProperty对象(即
hotel.datesAndPrices
),就可以将其视为Python列表。你知道吗相关问题 更多 >
编程相关推荐