Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何设置GeoPtProperty?谷歌应用程序引擎_Python_Python 2.7_Google App Engine_Google Cloud Datastore - Fatal编程技术网

Python 如何设置GeoPtProperty?谷歌应用程序引擎

Python 如何设置GeoPtProperty?谷歌应用程序引擎,python,python-2.7,google-app-engine,google-cloud-datastore,Python,Python 2.7,Google App Engine,Google Cloud Datastore,我有这个模型: class location(ndb.Model): geoLocation = ndb.GeoPtProperty() 我正在使用此函数声明位置模型: def careateLocationMode(cls,lon,lat): location1 = location() location1.geoLocation.lat = lat location1.geoLocation.lon = lon 但我得到了这个错

我有这个模型:

class location(ndb.Model):
      geoLocation = ndb.GeoPtProperty()
我正在使用此函数声明位置模型:

def careateLocationMode(cls,lon,lat):
        location1 = location()
        location1.geoLocation.lat = lat
        location1.geoLocation.lon = lon
但我得到了这个错误:NoneType对象没有属性lat

有什么问题吗?

来自

您可以使用两个浮点数(如ndb.GeoPt(52.37,4.88))或字符串ndb.GeoPt(“52.37,4.88”)来构造一个浮点数。(这实际上是与db.GeoPt相同的类)

所以任务是

location1.geoLocation = ndb.GeoPt(lat,lon)

您可以使用两个浮点数(如ndb.GeoPt(52.37,4.88))或字符串ndb.GeoPt(“52.37,4.88”)来构造一个浮点数。(这实际上是与db.GeoPt相同的类)

所以任务是

location1.geoLocation = ndb.GeoPt(lat,lon)