我有这个ListOfCoordinates
包含 5 个元组的列表(下图),每个索引对应于大脑两个区域的坐标。
我还有一个名为 brain_areas_ROIs
的变量,这是一本字典(下图),其中包含所有可能的大脑区域的名称。
所以我想将获得的所有坐标对的相应大脑区域存储在字典中,例如 dict = {0: 'Frontal_Med_Orb_L', 'Frontal_Sup_Medial_L', 1: 'Frontal_Med_Orb_R', 'Frontal_Sup_Medial_L'}
,等等等等。
我真的对此迷失了......有什么想法吗?
提前致谢!
最佳答案
这样的东西有用吗?我不确定你到底想要什么样的变量。我使用的两个变量是简短的示例,您可以用数据填充它们。
def main():
ListOfCoordinates = [
(2, 4),
(1, 5),
(6, 3),
(7, 0)
]
brain_areas_ROIs = {
0: "Precentral_L",
1: "Precentral_R",
2: "Frontal_Sup_L",
3: "Frontal_Sup_R",
4: "Frontal_Sup_Orb_L",
5: "Frontal_Sup_Orb_R",
6: "Frontal_Mid_L",
7: "Frontal_Mid_L"
}
print(brain_thing(ListOfCoordinates, brain_areas_ROIs))
def brain_thing(coordinates: list, brain_pos: dict) -> list:
brain_list = []
for coordinate in coordinates:
brain_list.append((brain_pos[coordinate[0]], brain_pos[coordinate[1]]))
return brain_list
关于python - 如何在Python中的列表中存储多个字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67796543/