我试图理解下面的代码。是矩阵的东西吗?

时间:2019-06-07 12:40:19

标签: python websocket

请向我解释以下部分代码在python中的作用/含义。 websocket_connections[client_socket][1]

完整摘录如下:

uuid = data['uuid'] #get the uuid from the data dictionary
    client_id_dict[uuid] = client_socket #add the uuid to the client id dictionary
    logger.info(f"successfully set the uuid for {client_socket}")

websocket_connections = {}
data = json.loads(message)


def registeruser(client_socket, data, websocket_connections):
    """ registeres a new username"""
    try:
        username = data.get('username', None) #if no username is submitted, set to None
        websocket_connections[client_socket][1] = username
        logger.info(f"Successfully registered username [{username}] for socket: {client_socket}")

    except Exception as e:
        logger.exception(f"There was an error registering username socket username for: {client_socket}")   

    return websocket_connections


edit:
i think the client_id_dic  is going to look like this
    client_id_dic = {"uuid": [xsocket1, 
                                xsocket2,
                                xsocket3,
                                ...]}
    ```

0 个答案:

没有答案