gpt4 book ai didi

python - Google App Engine 上的 ListProperty 与 StringListProperty

转载 作者:太空宇宙 更新时间:2023-11-03 12:42:27 25 4
gpt4 key购买 nike

我想存储整数列表(用户 ID),我应该将它们设为字符串并使用 StringListProperty,还是只使用 ListProperty,我想知道什么更优化,异构 ListProperty 的特定 StringListProperty(使用时只有整数)。

我需要将用户添加到列表中,直到达到一定数量,然后我为这些用户创建一个组实例(在单独的实体组中)。

最佳答案

StringListProperty 只是 ListProperty 的一个非常薄的包装器。除了元素类型之外没有任何有意义的区别。

来自 the code itself :

class StringListProperty(ListProperty):
def __init__(self, verbose_name=None, default=None, **kwds):
super(StringListProperty, self).__init__(basestring,
verbose_name=verbose_name,
default=default,
**kwds)

我建议将整数存储在普通的 ListProperty 中,因为这样您就可以在数据存储查询中正确地查询和排序它们,即数字,如果将它们转换为字符串,则无法轻松做到这一点。

关于python - Google App Engine 上的 ListProperty 与 StringListProperty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4797433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com