本文整理汇总了Python中location.Location.toDict方法的典型用法代码示例。如果您正苦于以下问题:Python Location.toDict方法的具体用法?Python Location.toDict怎么用?Python Location.toDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类location.Location
的用法示例。
在下文中一共展示了Location.toDict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Visit
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import toDict [as 别名]
class Visit(object):
'''
(String(hh:mm)) start
(String(hh:mm)) end
(Number (minutes)) duration
(Number (any unit)) load
(String or Array) type
'''
def __init__(self,lat,lng,name=None,start=None,end=None,duration=None,load=None,type=None):
# TODO: Type check parameters
self.location = Location(lat,lng,name)
self.start = start
self.end = end
self.duration = duration
self.load = load
self.type = type
'''
Serialize object to dictionary
'''
def toDict(self):
visit = {}
if self.location: visit["location"] = self.location.toDict()
if self.start: visit["start"] = self.start
if self.end: visit["end"] = self.end
if self.duration: visit["duration"] = self.duration
if self.load: visit["load"] = self.load
if self.type: visit["type"] = self.type
return visit
def toJson(self):
return json.dumps(self.toDict())