Индексация в Python dictВ этом примере показано, как получить и установить значения в словаре.
Создайте переменную словаря в MATLAB®.
customers = py.dict
customers =
Python dict with no properties.
{}
Заполните dict переменная с именами клиента и номерами счета и отображает результаты. Выход зависит от вашей версии Python®.
customers{'Smith'} = int32(2112);
customers{'Anderson'} = int32(3010);
customers{'Audrey'} = int32(4444);
customers{'Megan'} = int32(5000);
customerscustomers =
Python dict with no properties.
{'Audrey': 4444, 'Anderson': 3010, 'Smith': 2112, 'Megan': 5000}
Считайте номер счета для клиента Андерсона.
acct = customers{'Anderson'}acct = int64
3010
Преобразуйте в переменную MATLAB.
C = struct(customers)
C = struct with fields:
Audrey: 4444
Anderson: 3010
Smith: 2112
Megan: 5000
acct = C.Anderson
acct = int64
3010