也许这是一个愚蠢/简单的问题,但是我应该如何在python中解释这种类型的数组表示法呢。你知道吗
self.sessions[(recepientId, deviceId)]
我想把一些Python翻译成PHP。你知道吗
正如有人说的不清楚,对我来说更不清楚,所以我会把全部功能。但我不能做更多,我不太了解Python。你知道吗
def loadSession(self, recepientId, deviceId):
if self.containsSession(recepientId, deviceId):
return SessionRecord(serialized=self.sessions[(recepientId, deviceId)])
else:
return SessionRecord()
sessions变量的定义如下。你知道吗
self.sessions = {}
此代码只是试图在中的其他代码中查找SessionRecord自我会话(它是键值映射)by key,其中key是recipientId和deviceId的一对。你知道吗
<>在C++、爪哇、C等中,人们宁愿写一些类似的东西:(recepientId, deviceId)
是由两个对象组成的元组。self.sessions
是一个字典(即键值哈希映射)。你知道吗元组是键,通过执行
self.sessions[(recepientId, deviceId)]
从字典中检索相关值。 因此,它只是在哈希映射(在Python中称为字典)中查找特定值。你知道吗相关问题 更多 >
编程相关推荐