python - Google App Engine 上的 ListProperty 与 StringListProperty

标签 python google-app-engine list bigtable datastore

我想存储整数列表(用户 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/

相关文章:

java - 谷歌应用引擎,Java 框架?

java - 应用程序错误: 10 using Google Cloud Storage Java API to read a big zip file

python - 每组的 pandas 计算

Python-编写一个for循环来反向显示给定的数字

python - 如何反序列化 GeoServer WFS GeoJSON?

java - Google App Engine (Java) - 从 web.xml 重定向到 jsp

python - 如何递归调用python中的函数将列表中的每个元素拖到底部?

r - 基于平行向量的滤波向量

python - 如何从 CSV 中读取数据到嵌套的键值对中以供将来检索?

python - Pycharm3.0.1&Win7,当我调试我的webpy项目时,它输出“ImportError : cannot import name compile_command”